Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

when i have to use while

+14 votes
asked Jan 4 by Mozmel Mohmed (220 points)

2 Answers

+3 votes
answered Jan 6 by Vivek Rajawat (210 points)

Use while when the number of iterations is unknown and the loop must continue until a condition changes. It’s ideal for user input, retries, waiting for events, streams, queues, async tasks, or infinite loops. Avoid it when iteration count is fixed use for instead.

+2 votes
answered Jan 25 by Mohit kumar (220 points)
Use a while loop when a task must repeat until a condition becomes false and the number of iterations is unknown.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...