do...while Repetition Statement

The do...while repetition statement is similar to the while statement. In the while loop, the program tests the loop-continuation condition at the beginning of the loop before executing the rest of the loop's body. If the condition is false, the loop never executes. The do...while statement tests the loop-continuation condition after executing the loop's body; Therefore, the body always executes at least once.

The form of the do...while statement is

do {
   statement
} while (expression)

The body of the do...while statement should alwys be enclosed within braces to avoid confusion with the while statement. A reader may misinterpret the last line of the do...while statement as a while statement containing an empty statement.

Fook Yuen Sin - Team 1