Unable to find issue Please Hhelp

#include
using namespace std;
int main() {
int b,c;
char a=‘a’;
while(a!=‘X’||a!=‘x’)
{
cin>>a;
if(a==’+’)
{
cin>>b>>c;
cout<<b+c<<endl;
}
else if(a==’-’)
{
cin>>b>>c;
cout<<b-c<<endl;
}
else if(a==’’)
{
cin>>b>>c;
cout<<b
c<<endl;
}
else if(a==’/’)
{
cin>>b>>c;
cout<<b/c<<endl;
}
else if(a==’%’)
{
cin>>b>>c;
cout<<b%c<<endl;
}
else{
cout<<“Invalid operation. Try again.”<<endl;
}

}
return 0;

}

Hello @aviral989,

Please share your code using Online Coding Blocks IDE.
The way you have shared it has introduced many syntax errors to it.

STEPS:

  1. Open Online Coding Blocks IDE
  2. Paste your code and save it.
  3. Share the URL generated.

Hello @aviral989,

I apologies for replying this late.
Actually, I was out of Delhi due to some emergency.
I hope, you would understand.:blush:

Now, coming back to your doubt.

There are two problems with your code:

  1. You have created an infinite loop.
    Solution:
    Use logical AND operator instead of a logical OR.
    Reason:
    The loop should execute only if both conditions are true.

  2. It is printing the statement :
    Invalid operation. Try again.
    for a=‘x’ and a=‘X’, which is not required
    Reason:
    while loop
    Solution:
    Use do-while loop.

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

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.