From 3752d7bff4c4167e430d3f313b67908fff20a0f3 Mon Sep 17 00:00:00 2001 From: EdJaPe Date: Wed, 28 Jan 2026 11:49:50 -0800 Subject: [PATCH] prevents divide by Zero, resolves #61 --- main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index a495fc94..de691bf9 100644 --- a/main.cpp +++ b/main.cpp @@ -12,7 +12,12 @@ int main() std::cout << "Addition: " << x + y << std::endl; std::cout << "Subtraction: " << x - y << std::endl; std::cout << "Multiplication: " << x * y << std::endl; - std::cout << "Division: " << x / y << std::endl; + if(y == 0) { + std::cout << "Dividing by zero is not a number.\n"; + }else{ + + std::cout << "Division: " << x / y << std::endl; + } std::cout << "Remainder: " << x % y << std::endl; std::cout << "Square Root: " << sqrt(x) << std::endl; std::cout << "Square: " << pow(x, y) << std::endl;