do-while Loop in C Language

This “do-while loop C language Tutorial” post provides complete information about do-while loop including syntax, flow chart and code programs to be perfect in using do-while loop.


 

while : First checks the condition and then executes the block.
do-while : First executes the block and then checks the condition.

 

 

void main()
{
    int i=1;
    while(i>10)
    {
        printf(“i : %d\n”,i);
        ++i;
    }
}

 

void main()
{
    int i=1;
    do
    {
        printf(“i : %d\n”,i);
        ++i;
    }while(i>10);
}

 

Note : In do-while loop, though the condition is false first time, the statements defined inside the block executes at least once.

Share this