Why am I getting this error?

In the question ‘Basic Question’, I am getting the runtime execution error, please let me know what have i done wrong?

Hello @gaurisha please share your code by saving it on ide.codingblocks.com .
i will check it.

i have saved it by the name ‘basic calculator.cpp’. please check it and also let me know, what have i done wrong?

@gaurisha you have to share the link after saving the code.
after saving there you will get one link in the above tab please share that then only i can see that.
please do the same.

#include using namespace std; int main() { int n1, n2; char ch; cin>>ch; while(ch != ‘X’ && ch != ‘x’) { if(ch == ‘+’) { cin>>n1; cin>>n2; cout<<n1+n2; break; } else if( ch == ‘-’) { cin>>n1; cin>>n2; cout<<n1 - n2; break; } else if( ch == ‘’) { cin>>n1; cin>>n2; cout<<n1 * n2; break; } else if( ch == ‘/’) { cin>>n1; cin>>n2; cout<<n1/n2; break; } else if( ch == '’) { cin>>n1; cin>>n2; cout<<n1%n2; break; } else { cout<<“Invalid operation. Try again.”; } } return 0; }

Hello @gaurisha i have corrected your code:


i have commented the mistakes.
if you have any doubt you can ask here:
Happy Learning!!

runguard: warning: timelimit exceeded (wall time): aborting command runguard: warning: command terminated with signal 15

Still getting the same error

I got the correction. Thank you.

@gaurisha the code which i have given to you is passing all the test cases:


if you have any doubt you can ask here:
Happy Learning!!

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.