From d5c967bd8683569a39c27f2edcd5e9f7ced65525 Mon Sep 17 00:00:00 2001 From: Jordan Bailey Date: Mon, 2 Feb 2026 17:20:27 -0800 Subject: [PATCH 1/2] Handle divide-by-zero input (resolves #61) --- main.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 5411e7a3..09cda2b5 100644 --- a/main.cpp +++ b/main.cpp @@ -1,23 +1,34 @@ #include #include -using std::endl; using std::cin; using std::cout; +using std::endl; int main() { cout << "THE FIRST EXAMPLE MATH DISPLAY!\n"; cout << "Hi, please enter two whole numbers: "; - int x,y; + 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; + + if (y != 0) + { + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; + } + else + { + cout << "Dividing by zero is not a number." << endl; + cout << "Dividing by zero is not a number." << endl; + } + cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl; From f110010cd55e2ad767d8a3962306dca6addff41b Mon Sep 17 00:00:00 2001 From: Jordan Bailey Date: Mon, 2 Feb 2026 17:29:17 -0800 Subject: [PATCH 2/2] Handle divide-by-zero input (resolves #61) --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 09cda2b5..970ceb35 100644 --- a/main.cpp +++ b/main.cpp @@ -1,9 +1,9 @@ #include #include +using std::endl; using std::cin; using std::cout; -using std::endl; int main() {