From 664a6893cefc4f6797cad7220867e1804e5b9412 Mon Sep 17 00:00:00 2001 From: emmaisaway Date: Wed, 10 Sep 2025 11:11:28 -0700 Subject: [PATCH] Fix divide by zero error --- main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 958ba61..45fdfdb 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,11 @@ 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 << "Division: " << x / y << endl; + } else { + cout << "Division: divide by Zero error" << endl; + } cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;