From ed94b1a182c986ee940e96aec65e3795f626b452 Mon Sep 17 00:00:00 2001 From: Diego Alejandre Date: Wed, 2 Sep 2026 12:55:08 -0700 Subject: [PATCH] fix: divide by zero issue, close #61 --- main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index a495fc94..9d985695 100644 --- a/main.cpp +++ b/main.cpp @@ -12,8 +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; - std::cout << "Remainder: " << x % y << std::endl; + if (y == 0) { + std::cout << "Dividing by zero is not a number." << std::endl; + } 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;