Do While Loop
DO while loop: Unlike for and while loops, which test the loop condition at the top of the loop, the
do….while loop checks the condition at the bottom of the loop.
A do…while loop is similar to a while loop , except that a do…while loop is guaranteed to execute at
least one time.
Syntax:
do
{
Statement(s);
}
While (condition);
Notice that the conditional expression appears at the end of loop, so the statements in the loop execute
once before the condition is tested.
If the condition is true, the flow of control jumps back up to do, and the statements in the loop execute
again. This process repeats until the given condition is false.
Example:#---------------
#------------
Int main()
{
int a=10;
do
{
Cout<<a<<endl;
a=a+1;
}
While(a<20);
Return 0;
}