#include
using namespace std;
int main()
{
char ch;
long long int a, b;
do
{
cin >> ch;
switch(ch)
{
case’+’:
cin>>a>>b;
cout<<a+b<<endl;
break;
case’-’:
cin>>a>>b;
cout<<a-b<<endl;
break;
case’’:
cin>>a>>b;
cout<<ab<<endl;
break;
case’/’:
cin>>a>>b;
cout<<a/b<<endl;
break;
case’%’:
cin>>a>>b;
cout<<a%b<<endl;
break;
default:
cout<<“Invalid Operation.Try again.”;
break;
}
}
while(ch!= ‘x’ || ch!= ‘X’);
return 0;
Please tell the error
hello @dhruvtrehan45,
can u please save your code on coding blocks ide and send the saved link here.
the code u sent is not rendering properly
hello @dhruvtrehan45,
here is your code- https://ide.codingblocks.com/s/174319
errors:
a) line no 37 in place of || u should use && because u should continue ur loop only when ur ch!=‘x’ and ch!=‘X’
b) whenever u give ‘x’ or ‘X’ in your input ,your code should exit out of the loop without printing “Invalid Operation.Try again.” but in ur case ur are printing “Invalid Operation.Try again.” for every encounter of ‘x’ or ‘X’
c) line number - 36 ,you missed to print newline .
here is ur corrected code link - https://ide.codingblocks.com/s/174326
I hope you find this helpful
regards
Aman yadav
@dhruvtrehan45 @dhruvtrehan45
hey dhruv if you have any furthur issue regarding this problem then pls ask otherwise mark it as resolved
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.