for

The for keyword is used to create a loop construct. An initialization section, an expression section, and an update section immediately follow the keyword. A semicolon separates each section, and all appear together within at least one set of parentheses.

The initialization section allows the programmer to declare one or more local loop variables. Once the loop ends, these variables are no longer valid.

The expression section contains an expression that is evaluated to determine whether the loop should continue. A true result allows the loop to continue; a false result allows control to transfer to the statement following the loop body.

The update section allows the programmer to increment loop counters or perform other updates. Typically, the update section is used to increment or decrement whatever loop counters the programmer defines.

The following example shows a typical for loop construct:

for ( int i = 0; i < 10; i++ )