for Repetition Statement
}for repetition statement
§Specifies the counter-controlled-repetition details in a single line of code.
}When the for statement begins executing, the control variable is declared and initialized.
}Next, the program checks the loop-continuation condition, which is between the two required semicolons.
}If the condition initially is true, the body statement executes.
}After executing the loop’s body, the program increments the control variable in the increment expression, which appears to the right of the second semicolon.
}Then the loop-continuation test is performed again to determine whether the program should continue with the next iteration of the loop.
}A common logic error with counter-controlled repetition is an off-by-one error.
}The general format of the forstatement is
for ( initialization; loopContinuationCondition; increment )
statement
§the initialization expression names the loop’s control variable and optionally provides its initial value
§loopContinuationCondition determines whether the loop should continue executing
§increment modifies the control variable’s value(possibly an increment or decrement), so that the loop-continuation condition eventually becomes false.
}The two semicolons in the forheader are required.

