From ee34468c1c8ac49433a4fd1e03edaa6e8aa35899 Mon Sep 17 00:00:00 2001 From: Harrison Stidham Date: Mon, 31 Aug 2026 11:38:36 -0700 Subject: [PATCH] fixed divide by zero problem, close #61 --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 main.cpp diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index 5411e7a3..61bb0cae --- a/main.cpp +++ b/main.cpp @@ -16,8 +16,8 @@ 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; + y != 0 ? cout << "Division: " << x / y << endl : cout << "Dividing by zero is not a number." << endl; + if (y != 0) cout << "Remainder: " << x % y << endl; cout << "Square Root: " << sqrt(x) << endl; cout << "Square: " << pow(x, y) << endl;