From 7ca118aa670852b703c4a65b19d577211b847877 Mon Sep 17 00:00:00 2001 From: jalennaran Date: Mon, 8 Sep 2025 11:35:20 -0700 Subject: [PATCH] added if else statements to handle dividing by 0, closes #62 --- main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 958ba61..060a604 100644 --- a/main.cpp +++ b/main.cpp @@ -15,8 +15,12 @@ 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 << "Dividing by zero is not a number" << endl; + }else if(y != 0){ + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; + } cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;