The DO/WHILE statement loops one or many times
The DO/WHILE looping statement iterates one or more times:
DO
Statement 1
Statement 2
WHILE control_expression
- Execute the set of statements between the DO and the WHILE, and then repeat while the control_expression tests true at the end of an iteration of the loop.
- When the control_expression tests false at the end of an iteration of the loop, continue execution after the line containing the WHILE; dont do any more iterations.
- Some statement within the loop must cause some value in the control_expression to change from true to false, otherwise the control_expression will never test false and the looping will never stop.
- Because the control_expression is tested at the end of the loop, the set of statements is always executed at least once, even if the control_expression is false.