idk where i going wrong i checked the constraints , input and output still 3 test cases are giving wrong answer.
here’s my code:
#include
using namespace std;
int main()
{
char ch;
long long int n1,n2;
cin>>ch;
if((ch==’+’)||(ch==’-’)||(ch==’’)||(ch==’/’)||(ch==’%’))
{
switch(ch)
{
case ‘+’:
cin>>n1>>n2;
cout<<n1+n2;
break;
case ‘-’:
cin>>n1>>n2;
cout<<n1-n2;
break;
case '’:
cin>>n1>>n2;
cout<<n1*n2;
break;
case ‘/’:
cin>>n1>>n2;
if(n2!=0)
{
cout<<n1/n2;
}
break;
case '%':
cin>>n1>>n2;
if(n2!=0)
{
cout<<n1%n2;
}
break;
}
return 0;
}
else if((ch=='X')||(ch=='x'))
{
return 0;
}
else
{
cout<<"Invalid operation. Try again.";
}
return 0;
}