C do-While Loop

C do-While Loop , exit controlled loop on some occasions, it might be necessary to execute the body of the loop before the test is performed,  such situations can be handle with the help of do-while statement.

In do while statements the body of the do-while loop is executed at least once.

 

Example of do while Loop :-

#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
clrscr();
do
{
printf(“%d\t”,a);
a++;
}
while(a<=10);
getch();
}

Result :-

C Language do-while Loop

 

C do-While Loop Example :-

#include<stdio.h>
#include<conio.h>
void main()
{
int a=2;
clrscr();
do
{
printf(“%d\t”,a);
a=a+2;
}
while(a<=10);
getch();
}

Result :-

 C Language do while loop




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top