do_while
In do while loops also the loop execution is terminated on the basis of test condition. The main difference between do while loop and while loop is in do while loop the condition is tested at the end of loop body, i.e do while loop is exit controlled whereas the other two loops are entry controlled loops.
Note: In do while loop the loop body will execute at least once irrespective of test condition.
Syntax:
do
{
// statements
update_expression;
} while (test_expression);
Note: Notice the semi – colon(“;”) in the end of loop.
Flow Diagram:
1.Write a Program to display 1 to 10 numbers using do while loop.
#include<stdio.h>
void main()
{
int i=1;
do
{
printf(" %d\n",i);
i++;
}while(i<=10);
}
Output:
0 Comments