Wednesday, 19 September 2012

While loop

It executes one or more statements while the given condition remains true.It is useful when number of iterations is unknown.

Syntax

initialization
while (condition)
{
statement;
increment/decrement;
}

Flow chart




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

No comments:

Post a Comment