For Loop Structure:
- The initialization statement is executed before the loop starts, and it is executed only once. It is commonly used to initialize the loop variable.
- Conditional test is evaluated, if it is true, loop body will be executed. If it is false, the for loop is terminated, and the statement after the for loop will be run.
- Update statement is executed after the loop body is executed. It is usually used to increment or decrement the loop variable.
0 1 2 3 4 5 6 7 done
Common use of for loop:
- When the number of iterations is known from the outset.
Last modified: Saturday, 24 January 2015, 2:07 PM