The program works fine in another compiler but fails here

#include
using namespace std;
int main() {
char ch;
do {
cin>>ch;
int n1;
int n2;
cin>>n1;
cin>>n2;
int ans;
if(ch==’’) {
ans =n1
n2;
}

else if(ch==’+’) {
ans=n1+n2;}

else if(ch==’*’) {
ans=n1-n2;}

else if(ch==’/’){
if(n2==0){
cout<<“Invalid”;}
else{
ans=n1/n2;}}

else if(ch==’%’){
if(n2==0){
cout<<“Invalid”;}
else{
ans=n1%n2;}}

else if(ch==‘x’ || ch==‘X’) {
break;
}
else {
cout<<“Invalid Operation Try Again”;
}

cout<<ans<<endl;

}while(ch!=‘x’ || ch!=‘X’);

return 0;

}

@Abhishek4799 let me check your code.

@Abhishek4799 hey ,just take this condition as invalid: ```
if (ch != ‘x’ && ch != ‘X’)
cout<<“Invalid operation. Try again.”;
}
and baki invalid ki condtions hta do ,also use long long int in place of int ,or abhi thodi submitting me dikkt arhi hai thodi der me try krlena pls.

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.

Hey, I tried again after applying the mentioned corrections but its still not working Here is the updated code#include using namespace std; int main() { char ch; do { cin>>ch; long long int n1; long long int n2; cin>>n1; cin>>n2; long long int ans; if(ch==’’) { ans =n1n2; } else if(ch==’+’) { ans=n1+n2;} else if(ch==’*’) { ans=n1-n2;} else if(ch==’/’){ if(n2==0){ } else{ ans=n1/n2;}} else if(ch==’%’){ if(n2==0){ } else{ ans=n1%n2;}} else if(ch==‘x’ || ch==‘X’) { break; } else { cout<<"Invalid "; } cout<<ans<<endl; }while(ch!=‘x’ || ch!=‘X’); return 0; }

@Abhishek4799 hey,I have corrected your code,please check it:
https://ide.codingblocks.com/s/34717
Feel free to ask any doubt.