C For Loop

for loop

for loop is used to execute a set of statements repeatedly until a particular condition is satisfied. we can say it an open ended loop.
General format is,


for(initialization; condition; increment/decrement)

In for loop we have exactly two semicolons, one after initialization and second after condition.
In this loop we can have more than one initialization or increment/decrement, separated using comma operator. for loop can have only one condition.


//Write a Program to Print First 10 Natural Numbers using for loop.
void main()
    int i;
    for(i=1; i<=10; i++)
        printf("%d ",i);


Command Prompt
1 2 3 4 5 6 7 8 9 10

Share This Page on:

Ask Question