From a15dafef68d427e004863f5fccd418d22dea2e1f Mon Sep 17 00:00:00 2001 From: Tiggzzz Date: Mon, 8 Sep 2025 11:31:28 -0700 Subject: [PATCH 1/2] Fixed display for division by 0, closed #61 --- main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 958ba61..eb7357e 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,11 @@ int main() cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; - cout << "Division: " << x / y << endl; + if (y == 0){ + cout << "Dividing by zero is not a number.\n"; + }else{ + cout << "Division: " << x / y << endl; + } cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl; From 4aa5e02d7e92d7ec7baa7facb3b9b6e4f4834bca Mon Sep 17 00:00:00 2001 From: Tiggzzz Date: Wed, 10 Sep 2025 11:43:44 -0700 Subject: [PATCH 2/2] handles NaN errors closes #61 --- main.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/main.cpp b/main.cpp index a495fc9..aceb912 100644 --- a/main.cpp +++ b/main.cpp @@ -1,21 +1,27 @@ #include #include +using namespace std; + int main() { - std::cout << "THE FIRST EXAMPLE MATH DISPLAY!\n"; - std::cout << "Hi, please enter two whole numbers: "; + cout << "THE FIRST EXAMPLE MATH DISPLAY!\n"; + cout << "Hi, please enter two whole numbers: "; int x,y; - std::cin >> x >> y; - std::cout << "Addition: " << x + y << std::endl; - std::cout << "Subtraction: " << x - y << std::endl; - std::cout << "Multiplication: " << x * y << std::endl; - std::cout << "Division: " << x / y << std::endl; - std::cout << "Remainder: " << x % y << std::endl; - std::cout << "Square Root: " << sqrt(x) << std::endl; - std::cout << "Square: " << pow(x, y) << std::endl; + cin >> x >> y; + cout << "Addition: " << x + y << endl; + cout << "Subtraction: " << x - y << endl; + cout << "Multiplication: " << x * y << endl; + if (y==0){ + cout<<"Dividing by zero is not a number.\n"; + }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; }