From 5df624ae6ddfd717b4f48805188171a1128e28ad Mon Sep 17 00:00:00 2001 From: bgriego Date: Mon, 31 Aug 2026 11:40:16 -0700 Subject: [PATCH] fixed divide by zero, close #61 --- main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 5411e7a3..032fcebb 100644 --- a/main.cpp +++ b/main.cpp @@ -16,8 +16,15 @@ int main() 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 by Zero is bad" << endl; + } + else{ + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; + } + cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;