From d0e18ac15c9920ad9678e8cc233e42827343d7c1 Mon Sep 17 00:00:00 2001 From: dpantaleoni Date: Mon, 8 Sep 2025 12:32:17 -0700 Subject: [PATCH] resolved Handle NaN errors, closes#62 --- main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 958ba61..eacffcf 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include #include +#include using std::cin; using std::cout; @@ -8,14 +9,16 @@ using std::endl; int main() { cout << "Hi, please enter two whole numbers: "; - + int x,y; cin >> x >> y; cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; - cout << "Division: " << x / y << endl; + cout << "Division: " << + (y == 0 ? "Dividing by zero is not a number." : std::to_string(x / y)) + << endl; cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;