Wednesday, 19 September 2012

Do while loop

Do while loops are useful where loop is to be executed at least once. In do while loop condition comes after the body of loop.This loop executes one or more statements while the given condition is true.
Syntax
initialization
do
{
statement(s);
increment/decrement;
}
while (condition);

Flow chart

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

2 comments: