For Loop in C
Syntax for loop is used to repeatedly perform some task for specific number of times. It is also known as iterative statement. It is useful when you know in advance how many times you want to repeat the task.
In for loop first
the counter variable is initialized with the starting value in the initialization
part. After initialization the condition is checked. If the condition is true then
the statements written inside body of loop will executes. After executing statements
inside body of loop the control goes to the Iteration part where the value of the
counter variable is incremented or decremented. After changing the value of the
counter variable it again check the condition. Example int i; for (i=1;i<=10;i++) { printf(" %d ",i); } It will display 1 2 3 4 5 6 7 8 9 10 |
||||||