Skip to main content

C do while loops


Flow Control
C do while loops

C do while loops is very similar to the while loops, but it always executes the code block at least once and further more as long as the condition remains true. This is exit-controlled loop.
The basic format of do while loop statement is:
Syntax:
do
{
statement
(s);

}while( condition );
Figure – Flowchart of do while loop:
c-do-while

Example of a C Program to Demonstrate do while loop

Example:
#include<stdio.h>

int main ()
{
/* local variable Initialization */
int n = 1,times=5;

/* do loops execution */
do
{
printf
("C do while loops: %d\n", n);
n
= n + 1;
}while( n <= times );

return 0;
}
Program Output:

c-do-while-loop


Comments

For Programs Click Here