#include
using namespace std;
int main() {
char ch;
long long int a,b;
cin>>ch;
while(ch!=‘X’||ch!=‘x’){
switch(ch){
case '’:
cin>>a>>b;
cout<<ab<<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;
default :
cout<<“Invalid operation”;
}
cin>>ch;
}
return 0;
}
This is my code for calculator problem
You are using a wrong approach in your code. You need to use do while loop in your code, rather than only while loop, .Try to implement it using that only…