for (initialization; comparison; continuation) { ... }

Performs the initialization, then evaluates the comparison and repeats all instructions between the winged brackets as long as the comparison is true or non-zero. The continuation statement will be executed after the instructions and before the next repetition. This repetition of instructions is called a loop. Initialization and continuation can be any expression or function call. A for loop is often used to increment a counter for a fixed number of repetitions.



int i;
for(i=0; i<5; i++) // repeat 5 times
  x += i; 

See also:

if, while, break, continue, comparisons, for(open_trades)

► latest version online