Write a program that mimics a calculator. the program should take as input two integers and an arithmetic operation (+, -, * ot/) to be performed. It should then output the numbers, the operator, and the result. (for division, if the denominator is zero, output an appropriate message. Sample program output: Enter the first integer 25 Enter the second integer: 30 Enter operator: +(addition), (subtraction), * (multiplication), /(division): + 25 + 30 = 55
Expert Answer
code.cpp
#include <iostream>
using namespace std;
int main() {
int a, b, c;
char operation;
cout<<“Enter the first integer : “;
cin>>a;
cout<<“n Enter the second integer : “;
cin>>b;
cout<<“Enter Operator : + (addition) , – (subtraction) , * (multiplication), / (division) : “;
cin>>operation;
if(operation == ‘+’){
c = a+b;
cout<<a<<” + “<<b<<” = “<<c;
}
else{
if(operation == ‘-‘){
c = a-b;
cout<<a<<” – “<<b<<” = “<<c;
}
else{
if(operation == ‘*’){
c = a*b;
cout<<a<<” * “<<b<<” = “<<c;
}
else{
if(operation == ‘/’){
c = a/b;
cout<<a<<” / “<<b<<” = “<<c;
}
}
}
}
return 0;
}
OUTPUT: