do while loop in C++ by R4R Team

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;
}


output-

1
2
3
4
5
6
7
8
9
10

-In this program, we just print the value from 1 to 10 using the do while loop start 'i' value from 1 and print i then i++ then print and so on.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!