From 1ff35f341e56076b70ebdcac8b67a0fe9df3ac11 Mon Sep 17 00:00:00 2001 From: extragit Date: Wed, 5 Nov 2025 18:51:21 +0100 Subject: [PATCH 1/2] feat: Implemented a Calculator --- exercises/calculator.cpp | 54 ++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/exercises/calculator.cpp b/exercises/calculator.cpp index 013cc786..25112821 100644 --- a/exercises/calculator.cpp +++ b/exercises/calculator.cpp @@ -1,12 +1,50 @@ /* - Write a program that given two numbers as input make the main operations. + Write a program that given two numbers as input make the main operations. - Output: - Insert first number: 4 - Insert second number: 2 + Output: + Insert first number: 4 + Insert second number: 2 - SUM: 6 - Difference: 2 - Multiplication: 8 - Division: 2 + SUM: 6 + Difference: 2 + Multiplication: 8 + Division: 2 */ +#include + +using namespace std; + +int main(){ + int num1; + int num2; + + cout<< "Insert first number: "; + cin >> num1; + + if(cin.fail()){ + cerr<<"Error: The given value is not a number"<> num2; + + if(cin.fail()){ + cerr<< "Error: The given value is not a number"< Date: Thu, 6 Nov 2025 11:43:31 +0100 Subject: [PATCH 2/2] style: remove a space --- exercises/calculator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/calculator.cpp b/exercises/calculator.cpp index 25112821..0185d9f3 100644 --- a/exercises/calculator.cpp +++ b/exercises/calculator.cpp @@ -34,8 +34,7 @@ int main(){ exit(1); } - - cout<< endl<< + cout<