Do-While statement:
In some applications it is necessary to execute the body of the loop before the condition is checked; such situation can be handled by do statement.
At least once the body of loop will be executed.
do statement, first executes the body of the loop.
At the end of the loop, the test condition in the while statement is evaluated. If the condition is true, then it continues to execute body of the loop once again.
This process continues as long as the condition is true.
When the condition becomes false, the loops will be terminated and the control goes to next statement after while statement.
Example:
#include <stdio.h>
#include <conio.h>
void main()
{
int i=1;
clrscr();
printf("\n Odd numbers from 1 to 20 are \n");
do
{
if(i%2 ! = 0)
printf("\n %d", i);
i++;
}while(i<=20); /* The loop iterates till the value of i is less than or
equal to 20 */
getch();
}