Basic calculator problem

only one test case is working

#include
using namespace std;
int main() {
int n1,n2;
char ch;
cin>>ch;

while(ch!='X' || ch!='x'){
    switch(ch){
        case '+': 
          cin>>n1>>n2;
          cout<<n1+n2<<endl;
          break;
        case '-': 
          cin>>n1>>n2;
          cout<<n1-n2<<endl;
          break;

        case '*': 
          cin>>n1>>n2;
          cout<<n1*n2<<endl;
          break;
           case '/': 
          cin>>n1>>n2;
          cout<<n1/n2<<endl;
          break;

           case '%': 
          cin>>n1>>n2;
          cout<<n1%n2<<endl;
          break;
           default: cout<<"Invalid operation. Try again"<<endl;
           break;
       }
          cin>>ch;
    }
     return 0;

}

Hello @sk3657860,

Am I answering it the second time?

  1. There is a silly mistake:
    In the statement: “Invalid operation. Try again.”, the full stop i.e. ‘.’ is missing.

  2. The outer while loop should use logical and operator instead of logical or.

I have modified your code:

Suggestion:
Study the difference between and use of Different operators.

HINT:
&& : Will execute the enclosed statements if and only if all the conditions will satisfy.
||: Will execute the enclosing statements if any one or more conditions satisfies.

Hope, this would help.
Give a like if you are satisfied.