The ‘For’ Loop provides a concise Loop control structure. The general form of the ‘For’ Loop is:
{`for (initialization; test condition; increment)
{
//body of the loop
}`}
When the control enters For Loop the Variables used in For Loop is initialized with the initial value such as i = 0, counter = 0 etc.
The value which was initialized is then checked with the given test condition. The test condition is a relational expression, such as (i < some value) that checks whether the given condition is satisfied or not if the given condition is satisfied the control enters the body of the Loop or else it will exit the Loop.
The body of the Loop is entered only if the test condition is satisfied and after the completion of the execution of the Loop the control is transferred back to the increment part of the Loop. Instead of increment we can also use decrement.
The process goes on till the control Variable fails to satisfy the condition.
Example of For Loop:
#include <stdio.h>
#include <conio.h>
void main()
{
int i,x,val;
printf(“Enter the number for which you want to generate table: ”);
scanf(“%d”,&x);
for(i=1;i<11;i++)
{
val = x * i;
printf(“\n %d”, val);
}
return;
}