do...while

Executes the specified statements until the test condition evaluates to false. Statements execute at least once.

Syntax

do
statements
while ( condition );

Parameters

Parameter Description
statements Block of statements that is executed at least once and is re-executed each time the condition evaluates to true.
condition Evaluated after each pass through the loop. If condition evaluates to true, the statements in the preceding block are re-executed. When condition evaluates to false, control passes to the statement following do while.

Examples

In the following example, the do loop iterates at least once and reiterates until i is no longer less than 5.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.