C for Loop

For loop contain three parts i.e.


for(Initialization; Condition; Iteration)
statement block;

  • When we are working with for loop always execution will start from initialization block.
  • After initialization block control will pass to condition block, if condition is evaluated as true then control will pass to statement block.
  • After execution of the statement block control will pass to iteration block, from iteration it will pass back to condition.
  • Always repetition will happened beginning condition, statement block and iteration only.
  • Initialization block will be executed only once when we are entering into the loop first time.
  • When we are working with for loop everything is optional but mandatory to place two semicolons(;;)
  • When we are working with the for loop if condition part is not given then it will repeats infinite times, because condition part will replace it non-zero. So it is always true like for(;1;)
  • Whenever we are working with for loop it repeats in anti clockwise direction.
  • In for loop pre-checking process will be occurs. Before execution of the statement block, condition part will evaluated.
  • In for loop whenever the condition part is repeated with constant zero then it will repeats 1′ because number of instances became 1 at the time of compilation.
  • Always for loop execution process is faster than while loop.


Print numbers from 1 to 10

void main()
int i;
for(i=1;i<=10;i++) printf("%d",i); }

Powered by k2schools