Next:
while
Up:
Control Structures
Previous:
if
for
for (int i = 0; i < 10; i++) { cout i << " " << i*i; }
The three elements of a
for
-loop: ``starting at''; ``as long as''; ``do this''.
The condition (
i < 10
) is tested
before
the variable is changed (
i++
).
The variable is changed
after
all the code inside the
{ }
has been executed.
Any of the three elements of the
for
-statement can be empty.
for(;;)
means an endless loop.
Andreas Koeller
2000-06-04