From 90e0d0b87e78bc9130ac6b2b36ee55a4eb0488ae Mon Sep 17 00:00:00 2001 From: Omar Rodriguez-Bernal <20omarr04@gmail.com> Date: Mon, 8 Sep 2025 11:27:04 -0700 Subject: [PATCH] Added condition for divide by zero closes #61 --- main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 958ba61..a68ec36 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,12 @@ 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." << endl; + } + else{ + cout << "Division: " << x / y << endl; + } cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;