Do While Loop in C

The do while construct consists of a process symbol and a condition. First, the code within the block is executed, and then the condition is evaluated. If the condition is true the code within the block is executed again. This repeats until the condition becomes false. Because do while loops check the condition after the block is executed.

the do-while loop is an exit-condition loop. This means that the code must always be executed first and then the expression or test condition is evaluated.

Do While Loop

Syntax


do
{
	statement;
}while(condition);							
							

Example


#include
#include

void main()
{
	int i=1;
	clrscr();
	
	do
	{
		printf("\n%d",i);
		i++;
	}while(i<=10);
	getch();
}							
							
Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit