From 707e8de978f1749a582b44a58b2bfea60b3c8e1f Mon Sep 17 00:00:00 2001 From: Jennifer Date: Mon, 31 Aug 2026 11:38:41 -0700 Subject: [PATCH] Fix: divide by zero problem, close #61 --- main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 5411e7a3..a32ab20a 100644 --- a/main.cpp +++ b/main.cpp @@ -13,11 +13,16 @@ int main() 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 << "Dividing by zero is not a number." << endl; + } else { + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; + } cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;