+ 1
Built a simple calculater
using switch case property's
2 Antworten
+ 8
int main()
{
char operation;
float num1,num2;
cout << "Enter operator either + or - or * or /: ";
cin >> operation;
cout << "Enter two operands: ";
cin >> num1 >> num2;
switch(operation) {
case '+':
cout << num1+num2;
break;
case '-':
cout << num1-num2;
break;
case '*':
cout << num1*num2;
break;
case '/':
cout << num1/num2;
break;
default:
/* If operator is other than +, -, * or /, error message is shown */
cout << "Error! operator is not correct";
break;
}
return 0;
}
+ 2
You forgot to post the link so we could check out your calculator.
https://www.sololearn.com/Codes/