Monday, May 27, 2013

for loop

for loop

 
 A loop construct found in many procedural languages which repeatedly executes some instructions while a condition is true.
In C, the for loop is written in the form; 

for(INITIALISATION;CONDITION;INCRIMENTATON /DECREMENTATION )STATEMENT;
where INITIALISATION is an expression that is evaluated once before the loop, CONDITION is evaluated before each iteration and the loop exits if it is false, AFTER is evaluated after each iteration, and STATEMENT is any statement, including a compound statement within braces "
..", that is executed if CONDITION is true.
Syntex:

int i;
 for (i = 0; i < 10; i++);
        (INITIALISATION;CONDITION;INCRIMENTATON /DECREMENTATION )
 printf("Hello\n");

prints "Hello" 10 times.