From 89d3e1712836296adfd675693a483cd831d12e7e Mon Sep 17 00:00:00 2001 From: aajordan2 Date: Wed, 2 Sep 2026 11:41:50 -0700 Subject: [PATCH] fix divide by zero error --- main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 5411e7a3..60fdd661 100644 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,9 @@ 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; + } cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;