Thursday 16 February 2017

The do_while Statement

-It is exit-controlled loop statement.
-do-while loop will execute at least one time even if the condition is false initially.
-The do-while loop execute until the condition beccomes false.

Syantax:

do
{
       Body of the loop
}
while(test-condition);

Program :


#include<stdio.h>
#include<conio.h>

void main()
{
int sum=1,index=0;
do
{
index+=1;
sum=2*sum;
}
while(index>9);
printf("%d%d",sum,index);
getch();
}

Output :
2 1

No comments:

Post a Comment