From e38721b6b10993fe045158a509c5bb2fe22f47bc Mon Sep 17 00:00:00 2001 From: Adrianna Jewell Date: Mon, 31 Aug 2026 11:38:46 -0700 Subject: [PATCH 1/2] Fix: Divide by 0 error, close #61 --- main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 5411e7a3..cefdaa98 100644 --- a/main.cpp +++ b/main.cpp @@ -13,11 +13,16 @@ int main() int x,y; cin >> x >> y; + 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 << "Dividing by 0 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 62ab0442630cac609871abd28c06e96479d149c2 Mon Sep 17 00:00:00 2001 From: Adrianna Jewell Date: Wed, 2 Sep 2026 13:35:27 -0700 Subject: [PATCH 2/2] Fix: Square root issues with negative numbers, #430 --- main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index cefdaa98..882a859b 100644 --- a/main.cpp +++ b/main.cpp @@ -23,7 +23,11 @@ int main() cout << "Division: " << x / y << endl; cout << "Remainder: " << x % y << endl; } - cout << "Square Root: " << sqrt(x) << endl; + if (x<0) { + cout << "Square root of a negative number is not a number" << endl; + } else { + cout << "Square Root: " << sqrt(x) << endl; + } cout << "Square: " << pow(x, y) << endl; return 0;