From bb3b2a28a1b6ce60c7d0e3cb5f68aaa50e5449d3 Mon Sep 17 00:00:00 2001 From: atorrespena Date: Mon, 8 Sep 2025 11:43:45 -0700 Subject: [PATCH] handles NaN errors closes #61 --- main.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 958ba61..caf9ef6 100644 --- a/main.cpp +++ b/main.cpp @@ -10,15 +10,23 @@ 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 << "Remainder: " << x % y << endl; - cout << "Square Root: " << sqrt(x) << endl; - cout << "Square: " << pow(x, y) << endl; + if ( y == 0) + { + cout << " Division: Not a number error " << endl; + } + else + { + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; + cout << "Square Root: " << sqrt(x) << endl; + cout << "Square: " << pow(x, y) << endl; - return 0; + + } + return 0; }