< previous page page_469 next page >

Page 469
0469-01.gif
Thr syntax template for a For statement is
0469-02.gif
Expression1 is the While condition. InitStatement can be one of the following: the null statement (just a semicolon), a declaration statement (which always ends in a semicolon), or an expression statement (an expression ending in a semicolon). Therefore, there is always a semicolon before Expression1. (You don't see a semicolon in the syntax template. If we included one, you would have to use two semicolonsone to terminate InitStatement and another before Expression1.)
Most often, a For statement is written such that InitStatement initializes a loop control variable and Expression2 increments or decrements the loop control variable. Here are two loops that execute the same number of times (50):
for (loopCount = 1; loopCount <= 50; loopCount++)
    .
    .
    .

for (loopCount = 50; loopCount >= 1; loopCount--)
    .
    .
    .
Just like While loops, Do-While and For loops may be nested. For example, the nested For structure

 
< previous page page_469 next page >