Basic calulator

Actually this is a code of basic calculator and it is passing all the test cases but when i am trying this with some random input it giving wrong output. Can you please point out my mistake

#include using namespace std; int main() { while(1) { char ch; cin>>ch; if(ch==’+’||ch==’-’||ch==’’||ch==’/’||ch==’%’) { long long int n1,n2,n3; cin>>n1>>n2; if(ch==’+’) n3=n1+n2; else if(ch==’-’) n3=n1-n2; else if(ch==’’) n3 = n1*n2; else if(ch==’/’) { if(n2==0) break; else n3 = n1/n2; } else if(ch==’%’) { if(n2==0) break; else n3 = n1%n2; } cout<<n3<<endl; } else if(ch==β€˜X’||ch==β€˜x’) break; else { cout<<β€œInvalid operation. Try again.”<<endl; continue; } } return 0; }

what input u r giving? @agarwaldaksh360_2bae042448e62c08

9/3,2*2,8-3 these are some inputs

9/3,2*2,8-3 @talhashamim001

9/3,6*2,8-2 these are some inputs that i am giving

9/3,6*2,8-2 these are some inputs that i am giving bug

hi @agarwaldaksh360_2bae042448e62c08 buddy u r giving wrong input
first give operator than operande
eg --> / 9 3 X

oh ok but can there be another code where it is not necessary

@agarwaldaksh360_2bae042448e62c08,
rn proceed with the course you will learn everything dont worry, read about strings and arrays then u can try

why rhere is 1 in the bracket of while loop

that will continue the while loop till you dont break it @agarwaldaksh360_2bae042448e62c08

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.