Doubt in my code

Here is my code. When I give input as X then also it s not terminating and taking more inputs from me. Why?

hello @yashsharma4304do you know the working of the do while loop ?

i mean do while loop will run for one time irrespective of the condition in the while loop .
but you can rectifythis by using while loop .

I was also trying to use while loop but when I use while loop then it checks the condition at first time also when ch contains garbage value. And it may cause termination of program.

And now also it is working in the same way.

@yashsharma4304 see this code :

1 Like

Ok it is working but what was the problem in that code. But now when I made some changes in your code according to my comfort. Then it’s not working.

Here is my code :

@yashsharma4304 you are not passing x to stop the program .

Ok. :slightly_smiling_face:

@yashsharma4304 if you feel that your doubt is cleared please mark this doubt as resolved and please do give the star ratings as well.
Happy Learning !!

1 Like