Module 6 · Loops and Jump Statements
do while: the Loop That Runs at Least Once
Free with an accountReading
Maria's till asks for a quantity, and it has to ask at least once. There is nothing to check until somebody types a number. It also has to refuse 0, because a quantity of 0 is not an order. It is a customer who changed their mind at the counter.
Checking what this lesson needs for you…
What is inside do while: the Loop That Runs at Least Once
- do while: the body first, the question after
- The semicolon after while
- Zero passes or one: the same false condition in both loops
- Asking until the answer is valid
- Clearing a bad line, and stopping when input ends
- A menu that runs until 0
- while or do while?