From a820aee4dc16e78be522804b1cdd60f2e1c39168 Mon Sep 17 00:00:00 2001 From: Elijah Beverley Date: Mon, 2 Feb 2026 12:46:38 -0800 Subject: [PATCH 1/2] Fix NaN error by handling division by zero Closes #61 --- main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.cpp b/main.cpp index a495fc94..2bc39dc4 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,14 @@ int main() std::cout << "Remainder: " << x % y << std::endl; std::cout << "Square Root: " << sqrt(x) << std::endl; std::cout << "Square: " << pow(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; + } return 0; } From 8fef59b0a9ae7acbb5f28a923900a1cafa3df4d1 Mon Sep 17 00:00:00 2001 From: Elijah Beverley Date: Mon, 2 Feb 2026 15:03:09 -0800 Subject: [PATCH 2/2] I added the division by zero --- main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.cpp b/main.cpp index 2bc39dc4..1577804d 100644 --- a/main.cpp +++ b/main.cpp @@ -25,5 +25,9 @@ int main() std::cout << "Division: " << x/y << std::endl; } + cout << "Remainder: " << x % y << endl; + cout << "Square Root: " << sqrt(x) << endl; + cout << "Square: " << pow(x, y) << endl; + return 0; }