Basic Calculator

Test case 2, Test case 4,Test case 5 is fail

@faizan_1402 send me your code i will check on it.

1 Like

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;

}

@faizan_1402 you haven’t change line for your default case.

@faizan_1402 mark this doubt as resolved if you don’t have any further queries.

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.