• CALL US: +91-8561868421
  • Address: Plont No 67 OM Shiv Colony Jhotwara Jaipur-12

C - do while loop control


do while loop control

The do..while loop is similar to the while loop with one important difference. In C programming language, a do while loop is a control flow statement that executes a block of code at least once, and then repeatedly executes the block, or not, depending on a given boolean condition at the end of the block. The do while construct consists of a process symbol and a condition.

The syntax of the do while loop is as follows:

do{ 
   statements;
}
while(condition);    
#include
#include
void main()
{
    int n = 1; // declare and initialize n to 1
    do
    {
        if(n % 3 == 0)
        {
            printf("%d ", n); // print the value of n
        }
        n++;
    }while(n < 100>

Output

3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 
66 69 72 75 78 81 84 87 90 93 96 99