Wednesday, 19 September 2012

For loop

For loops are used when the number of iterations is known before entering the loop. It is also known as counter-controlled loop.
Syntax

for (initialization;condition;increment/decrement)
{
statement()s;
}

Flow chart

Example
#include<stdio.h>
#include<conio.h>
void main (void)
{
int n;
for(n=1;n<=5;n++)
{
printf("\n %d",n);
}
getch();
}

No comments:

Post a Comment