From 116b6ce093ff383b5c0c0de11d13f439bbc60d28 Mon Sep 17 00:00:00 2001 From: tojusts Date: Tue, 17 Feb 2026 16:25:09 -0800 Subject: [PATCH] Fixes divide by zero error, Resolves #61 --- main.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 652ca31c..b2863038 100644 --- a/main.cpp +++ b/main.cpp @@ -16,16 +16,14 @@ int main() 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"; + if (y == 0) { + cout << "Cannot divide by zero\n"; + } else { + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; } - else{ - cout << "Division: " << x / y << std::endl; - } - cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl; - return 0; -} +} \ No newline at end of file