do while loop control statement

A do-while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time. The do-while loop checks its condition at the bottom of the loop after one time execution of do.

Syntax

do
{
statement(s);
}
while( condition );

The condition appears at the end of the loop, so the statement(s) in the loop executes once before the condition is tested.

Flow Diagram

If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop executes again. This process repeats until the given condition becomes false.
If the condition becomes false statement following the while statement will be executed.

Example

write a program to print 'n' until its value is less than 20 using do-while.