how to use do while-loop in a C++ code

In this loop, the statement block gets executed first, and then the condition is checked. This is called an Exit-controlled loop in C++.
This loop will execute at least once whether the condition is true or false.This type of loop is mainly used in menu driven programs where we have to execute the loop minimum one time.

Syntax:

do
{
    //statement block
}
While(condition);
 
//use header files syntax according to the compiler

Examples::
 
#include<iostream.h>
#include<conio.h>
void main()
{
    int i=1;
    do
    {
        cout<<i<<" ";
        i++;
    }    while(i<=5);
 getch();
}
 
//output:  1 2 3 4 5
==========================================================    
 
#include<iostream.h>
#include<conio.h>
 
void main()
{
    int i=1;
    do
    {
        cout<<"hello anand ";
        i++;
    }    while(i<=3);
 getch();
}
 
//output:: hello anand hello anand hello anand 
==========================================================
   
#include<iostream.h>
#include<conio.h>
 
void main()
{
     int i=15;
     do
     {
        cout<<"hello anand ";
        i++;
     }    while(i<=5);
     getch)_;
}

//output:: hello anand
The initial value of i is 15 but when we enter the loop first we print the "hello anand"
and then the value of i is incremented by 1 and i becomes 16. Now we check whether 16 is less than 5 or not so we exited the loop.
The above loop executes exactly one time .