Statements: do-while loop

The do-while loop iteration statement lets you repeat a nested statement.

Syntax

dostatementwhile(condition)

Discussion

The do-while loop statement executes the nested statement repeatedly as long as the condition evaluates to the boolean value true. Unlike the while statement, the condition is evaluated at end of every iteration, resulting in the nested statement being executed at least once. To execute multiple statements within the loop, you can group those together within a block statement. For example:

array int32 values[ 16 ]; var int32 inx = 0; var int32 sum = 0; [ ... ] // Sum the array values until the value 1000 has been exceeded or // there is no more array values to add. do { sum = sum + values[ inx ]; inx = inx + 1; } while (( sum <= 1000 ) && ( inx < values.size ));