From 4b57e86da726fd40499800afecda210bdbd9815c Mon Sep 17 00:00:00 2001 From: Peixuan Li Date: Mon, 8 Sep 2025 11:27:53 -0700 Subject: [PATCH] Handle NaN errors closes #61 --- main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.cpp b/main.cpp index 958ba61..97b599c 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,13 @@ int main() cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; + + if(y == 0){ + cout << "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;