Skip to main content

examples of do while loop in c

/*
/*
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

Popular posts from this blog

example of typecasting in c

/*Type Casting in C Typecasting allows us to convert one data type into other. */ //simple example to cast int value into the float. #include <stdio.h>    int   main (){   float   f = ( float ) 9 / 4 ;     printf ( "f : %f \n " ,  f  );     return   0 ;   }