/*
/*
do while loop
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:
initialization expression;
do
{
// statements
update_expression;
}
while (test_expression);
*/
// C program to illustrate do-while loop
#include <stdio.h>
int main()
{
int i = 0; // Initialization expression
do
{
// loop body
printf( "Hello World\n");
// update expression
i++;
}
while (i < 6); // test expression
return 0;
}
Comments
Post a Comment