Basic calculator

#include
#include<math.h>
using namespace std;

int main()
{
int ch;
int n1,n2,res;
cin>>ch;
while(ch==’+’ || β€˜-’ || β€˜*’ || β€˜/’ || β€˜%’)
{
cin>>n1;
cin>>n2;
if(ch==’+’)
{
res=n1+n2;
cout<<res<<endl;
}

	else if(ch=='-')
	{
		res=n1-n2;
		cout<<res<<endl;
	}

	else if(ch=='*')
	{
		res=n1*n2;
		cout<<res<<endl;
	}

	else if(ch=='/')
	{
		res=n1/n2;
		cout<<res<<endl;
	}

	else if(ch=='%')
	{
		res=n1%n2;
		cout<<res<<endl;
	}

	else if(ch=='x' || 'X')
		break;
	else
	{
		cout<<"Invalid operation. Try again."<<endl;
		continue;
	}
}
	return 0;

}

Why is it not printing any output…?

The condition in while loop is wrong , you can’t use direct || symbol. You have to mention every time the left of condition as well as right of condition.
Like this -:
while( ch==’+’ || ch == β€˜-’ || ch == β€˜*’ || ch == β€˜/’ || ch==β€˜%’ )

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.

still not passing all the test cases

Hello @dsdishu99 i have corrected your code and now it is passing all the test cases;


i have commented all the unnecessary things you have written in the code :
if you have any doubt you can ask here:
Happy Learning!!

test cases not passing

@dsdishu99 try this https://ide.codingblocks.com/s/605128

where was the mistake it is passing all TC now

@dsdishu99 no endl after the wrong input try again statement

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.