SHOWING MY CODE IS TOO SLOW TO EXECUTE ON COMPUTER

HERE IS MY CODE, PLEASE LET ME KNOW MY MISTAKE AS I CAN’T FIND IT.

#include
#include
using namespace std;

int main () {
char ch;

int N1 , N2;

int max = INT_MAX;

int counter = 1;
do {
    cin>>ch>>N1>>N2;

    switch (ch) {
        case '+':
            cout<<(N1 + N2)<<endl;
            break;
        
        case '-':
            cout<<(N1 - N2)<<endl;
            break;

        case '*':
            cout<<(N1 * N2)<<endl;
            break;
        
        case '/':
            if (N2 != 0){
                cout<<(N1 / N2)<<endl;
            }
            break;

        case '%':
            if (N2 != 0){
                cout<<(N1 % N2)<<endl;
            }
            break;

        case 'X':
        case 'x':
            break;

        default:
            cout<<"Invalid operation. Try again."<<endl;
    }
    counter++;

}
while (counter <= max);

return 0;

}

hi @sinchan1509_1a917d7b6cc3cbb9
refer this code -->

Why my code was not working?? What was wrong in my code??

counter <= max
bcoz of this ur code goes in infinite loop…
refer to code I sent u…

Sir i understood your code and tried to run it but its again showing the same problem again when submitting

click on submit button, it will pass all test cases…

ok sir problem solved

1 Like

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.

i got it where I was performing mistake

Thank you so much sir for your help

1 Like