for

for(init;expression;coding2)

{

coding;

}

 

First init is executed, then if expression is true the block is executed, then coding2 is executed, then expression is evaluated again.  The for statement repeats until expression is false.  You can get into infinite loops with the for statement.

 

Example: This example (taken from the official manual) initializes an array of length 10 with the values 1- 10

for (i=0; i<=9; i+=1)

{

list[i] = i+1;

}

 

Abyssal_Nuclei - Revision #1