From f1338b521e322c0a518ce0c0befbf132ee56ba08 Mon Sep 17 00:00:00 2001 From: Braden Currah Date: Mon, 8 Sep 2025 11:30:54 -0700 Subject: [PATCH 1/2] fix div by zero (closes #61) --- main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 958ba61..1fba013 100644 --- a/main.cpp +++ b/main.cpp @@ -15,8 +15,13 @@ 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 << "Division: " << "Dividing by zero is not a number." << endl; + cout << "Remainder: " << "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; From 01b61def41737f307b12ced021fcbab70ca3d4e9 Mon Sep 17 00:00:00 2001 From: Braden Currah Date: Wed, 10 Sep 2025 11:25:52 -0700 Subject: [PATCH 2/2] add namespace identifiers --- main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/main.cpp b/main.cpp index b9c0eed..6068f7f 100644 --- a/main.cpp +++ b/main.cpp @@ -8,19 +8,19 @@ int main() int x,y; - cin >> x >> y; - cout << "Addition: " << x + y << endl; - cout << "Subtraction: " << x - y << endl; - cout << "Multiplication: " << x * y << endl; + std::cin >> x >> y; + std::cout << "Addition: " << x + y << std::endl; + std::cout << "Subtraction: " << x - y << std::endl; + std::cout << "Multiplication: " << x * y << std::endl; if (y == 0) { - cout << "Division: " << "Dividing by zero is not a number." << endl; - cout << "Remainder: " << "Dividing by zero is not a number." << endl; + std::cout << "Division: " << "Dividing by zero is not a number." << std::endl; + std::cout << "Remainder: " << "Dividing by zero is not a number." << std::endl; } else { - cout << "Division: " << x / y << endl; - cout << "Remainder: " << x % y << endl; + std::cout << "Division: " << x / y << std::endl; + std::cout << "Remainder: " << x % y << std::endl; } - cout << "Square Root: " << sqrt(x) << endl; - cout << "Square: " << pow(x, y) << endl; + std::cout << "Square Root: " << sqrt(x) << std::endl; + std::cout << "Square: " << pow(x, y) << std::endl; return 0; }