In C++,
There are four types of loops:
-for loop
-while loop
-do while loop
-foreach loop
Do While loop:
Do while loop is the Exit control loop in C and C++ language;
Syntax-
initialization;
do{
body;
increament/decreament;
}while(condition);
Print value from 1 to 10 using do while loop:
program:
#include
using namespace std;
int main()
{
int i;
i=1;
do{
cout<< i;
i++;
}while(i<=10)
return 0;
}
1
2
3
4
5
6
7
8
9
10