------------------------------------------------------------------------------
MC logo
For Loops
[^] Code Examples
------------------------------------------------------------------------------
<<Comparison Pitfall Average For Loop>>
The for statement is similar to Java's.

Abbreviates a while loop.

for(init;test;incr)stmt
      Abbreviates...
init;while(test){stmt incr;}

for(i = 1; i <= 10; ++i) printf("%d\n", i);
      Abbreviates...
i = i; while(i <= 10) { printf("%d\n", i); ++i; }

Pure C forbade declarations in for loops until C99. Many compiliers will still forbid. it.

Reading: Ch. 8
<<Comparison Pitfall Average For Loop>>