Free programming examples and instructions

C program to study 'do-while' loop

How do while loop is working in c program with syntax and example

by Krishna viswambharan

Posted on 21 Aug 2017 Category: C Views: 357

Edited on 25 Aug 2017

Familiarization of 'do-while' loop

In the last sections we have seen that how to use the ‘for loop’ and ‘while loop’. One of the other important loop in C programming is ‘do..while loop’. Let us see how it works.

The syntax is given as follows :-


}while(condition test);

do-while loop is similar to while loop, but there is one difference between these two loops. do-while runs at least one even if the test condition is false at first place.

Notice that the condition test is given at the bottom of the loop. So we can say that loop will run at least once even if the condition is false.

When the condition is true , the control goes back to ‘do’

#include <stdio.h>
#include <conio.h>
void main()
    int count=1;
          printf(ā€œ\n %dā€,count); // print the value in the variable 'count' even though the condition is false.

Related Article

C program to study while loop

Leave a Comment: