For Loop
The for statement is a perfect loop that uses three expressions. The first expression contains initialization, the second contains the condition, and the third contains the updating expression.
A for loop is used when a loop must be executed a certain number of times. We can do the same with while loop, but the for loop is easier to read and more natural to count the loops.

Syntax:
for (expr1; expr2; expr3)
{
statement(s);
}
expr1: initialization, expr2: condition, expr3: updating expression.
Expr1 is executed when the for starts, expr2 is the condition and is tested before every iteration and if the condition fails, the body is not executed. Finally, expr3 is the update expression and is executed at the end of each loop/ iteration.
C allows the loop condition to be controlled inside the for a statement itself, updating the condition can be done in the body of the for statement. If ++(post and pre) or — (post or pre)operators are used in the update part of the for loop, both has the same effect.
Never use statements such as return inside the for statement and it doesn’t need ‘;’ at the end of the statement.
Eg:
for(i=0;i<=10;i++) —right
for(i=0;i<=10;i++);—wrong
Example Program:
To print even values up to the limit using for loop
#include<stdio.h>
main()
{
int m,y;
printf("\n Enter the limit: ");
scanf("%d",&m);
printf("\n");
for(y=2;y<=m;y=y+2) // here to obtain even values we updated y with 2 increments
printf("%d\t",y);
printf("\n%d values printed",m/2);
}
Output:
Example Program:
To find whether the entered number is palindrome or not using for loop
#include<stdio.h>
main()
{
int m,i=1,k=0,y,p;
printf("\nEnter any value : ");
scanf("%d",&m);
p=m;
for(i=1;i<=m;i)
{
y=m%10;
k=k*10+y;
m=m/10;
}
if(k==p)
printf("\nThe entered number %d is palindrome",p);
else
printf("\nThe entered number %d is not a palindrome number",p);
}
Outputs: