In the question âBasic Questionâ, I am getting the runtime execution error, please let me know what have i done wrong?
Why am I getting this error?
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.