6.8.5 Iteration statements

Syntax

1

iteration-statement:

while ( expression ) statement

do statement while ( expression ) ;

for ( expressionopt ; expressionopt ; expressionopt ) statement

for ( declaration expressionopt ; expressionopt ) statement

Constraints

2

The controlling expression of an iteration statement shall have scalar type.

3

The declaration part of a for statement shall only declare identifiers for objects having storage class auto or register.

Semantics

4

An iteration statement causes a statement called the loop body to be executed repeatedly until the controlling expression compares equal to 0. The repetition occurs regardless of whether the loop body is entered from the iteration statement or by a jump.[1]

5

An iteration statement is a block whose scope is a strict subset of the scope of its enclosing block. The loop body is also a block whose scope is a strict subset of the scope of the iteration statement.

Footnotes