Complier showing wrong o/p

Why this line “Invalid operation. Try again.”
is showing unlimited no. of times for the given test case ?? It should be displayed only once !

@namandubey20, you must have got stuck in an infinite loop. Share your code using ide.codingblocks.com so that I can have a look at it and help resolving your doubt.

But i have turned on the collaboration mode. Can’t u access my code ??

Sorry @namandubey20, but I am no able to access your code.

This is the code. Please check this.

@namandubey20 While you were away, I worked out a solution for this question, would you like to see it and compare it with your code?
This will help you understand 2 different approaches.

Ok but my code is showing correct answer in code blocks for the given test case.

@namandubey20 here try this code : https://ide.codingblocks.com/s/131017

Also, I tried running your code in code blocks, it’s working the same way it is working on online ide, it has to stop after we input X, but in codeblocks it is asking for input again.

So what is the error ?

@namandubey20 Just change the while loop condition from
(ch!=‘X’ || ch!=‘x’) to (ch!=‘X’ && ch!=‘x’).

If we go by the original condition, then even after entering either of X or x the loop will run because one condition will always remain true despite the other being false.