Basic calculator in c++

i am unable to solve … everytime its giving tle… pls give the code in c++

hi @rabimajumder08
Simply Put a loop and take input operator and then take input of two digits and then perform the operation till the user inputs ‘x’ or ‘X’.

refer this code -->

#include<iostream>
using namespace std;
int main() {
	int a,b,c;
	char ch;
	do
	{
		cin>>ch;
        if((ch=='X')||(ch=='x'))
        {
            break;
        }
        else if(ch=='+' || ch=='-' || ch=='*' || ch=='/' || ch=='%')
        {
			cin>>a>>b;
		switch(ch)
		{
			case '+':c=a+b;
			break;
			case '-':c=a-b;
			break;
			case '*':c=a*b;
			break;
			case '/':c=a/b;
			break;
			case '%':c=a%b;
			break;
		}
		cout<<c<<endl;
        }
		else
		{
			cout<<"Invalid operation. Try again."<<endl;
		}
	}
	while(1);
	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.