From f87d5d695f76620eb5e0c420c96faa3f57c07ba5 Mon Sep 17 00:00:00 2001 From: Alexey Gavrushenko Date: Mon, 31 Aug 2026 11:38:38 -0700 Subject: [PATCH 1/2] fix: the length of int depends on C++ implementation, resolves #340 --- main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 5411e7a3..85d1283c 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include #include +#include using std::endl; using std::cin; @@ -8,11 +9,16 @@ using std::cout; int main() { cout << "THE FIRST EXAMPLE MATH DISPLAY!\n"; - cout << "Hi, please enter two whole numbers: "; + cout << "Hi, please enter two whole numbers\n"; + cout << "(Limited to whole numbers between -2,147,483,648 and 2,147,483,647):"; - int x,y; + int32_t x,y; + + if (!(cin >> x >> y)) { + std::cout << "Error: The number is not within the limit.\n"; + return 1; + } - cin >> x >> y; cout << "Addition: " << x + y << endl; cout << "Subtraction: " << x - y << endl; cout << "Multiplication: " << x * y << endl; From 7954ab55c4c3d0f77ce42027ef0b93148f3dfb64 Mon Sep 17 00:00:00 2001 From: Alexey Gavrushenko Date: Wed, 2 Sep 2026 11:41:19 -0700 Subject: [PATCH 2/2] Fixed formatting --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 85d1283c..f1ff30dc 100644 --- a/main.cpp +++ b/main.cpp @@ -10,13 +10,13 @@ int main() { cout << "THE FIRST EXAMPLE MATH DISPLAY!\n"; cout << "Hi, please enter two whole numbers\n"; - cout << "(Limited to whole numbers between -2,147,483,648 and 2,147,483,647):"; + cout << "(Limited to whole numbers between -2,147,483,648 and 2,147,483,647): "; int32_t x,y; if (!(cin >> x >> y)) { std::cout << "Error: The number is not within the limit.\n"; - return 1; + return 1; } cout << "Addition: " << x + y << endl;