Test case 2, Test case 4,Test case 5 is fail
Basic Calculator
Ok sir
#include
using namespace std;
int main() {
int a,b;
char ch;
int c=1;
while(c){ // loop finite time run
cin >>ch;// character value
switch(ch){
case '+':
cin>>a >>b ; cout<< a+b<<endl; break;
case '-':
cin>>a >> b; cout<< a-b << endl; break ;
case '*' :
cin >>a >> b; cout<< a*b <<endl; break ;
case '/' :
cin >> a>> b; cout << a/b << endl;
break ;
case '%':
cin >> a>>b; cout << a%b <<endl; break;
case 'x':
case 'X': c=0;break;
default : cout<< "Invalid operation. Try again.";
}
}
return 0;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.