# do

The keyword defines a loop which is executed as long as the loop condition holds. The loop condition shall be checked at the end of each new loop iteration. If the loop condition does not hold, then the loop is exited and execution shall continue with the statement, which immediately follows the loop.

- Using the while keyword alone a loop can be defined where the loop condition is checked at the beginning of each loop operation.

Related keyword:

- while

### do { statement_block } while ( condition);

- The do keyword introduces the loop.

- statement_block contains one or more statements. The block will be executed in a loop provided condition is true.

- the while keyword precedes the loop condition.

- condition is a Boolean expression. It is checked at the end of each new loop iteration. If it evaluates to false, the loop terminates.

Example 1:

var integer ii := 3;
do {ii:= ii+2 } while (ii<=10)

The loop variable ii is declared in the first line and it is given the initial value 3. In the second line, a loop is defined. In the statement block the index variable is increased by 2 every time the loop is executed. The loop execution terminates when the index value will have a value greater than 10. The loop will be executed 6 times.

BNF definition of do