for Repetition Statement

In most cases, the for statement can be represented with an equivalent while statement as follows

initialization

while (expression) {
   statement
   increment
}

The one exception occurs when the increment expression in the while statement follows a continue statement. In this case, the increment does not execute before the program evaluates the loop-continuation condition, so the while statement does not execute in the same manner as the for statement.

The for statement is typically used for count-controlled repetition.

<< Back
Fook Yuen Sin - Team 1