How to know the do while loop in C programming [closed]

Well: Hope the following helps you.

  • Unlike for and while loops, which test the loop condition at the top
    of the loop, the do…while loop in C programming language checks its
    condition at the bottom of the loop
  • A do…while loop is similar to a while loop, except that a do…while loop is guaranteed to execute at least one time.

A sample syntax would be:



Notice that the conditional expression appears at the end of the loop, so the statement(x) in the loop execute once before the condition is tested.

If the condition is true, the flow of control jumps back up to do, and the statement(x) in the loop execute again. This process repeats until the given condition becomes false.

Try this code and you will be good:

#include <stdio.h>

int main ()
   // local variable definition 
   int x = 5;

   // do loop execution 
       printf("value of x: %d\n", x);
       x = x + 1;
   }while( x < 10 );

   return 0;

Browse More Popular Posts

Leave a Comment