While loop in C++ by R4R Team

In C++,
There are four types of loops:
-for loop
-while loop
-do while loop
-foreach loop

While loop:
while loop is the Entry control loop in C and C++ language;

Syntax-
initialization;
while(condition)
{
body;
increament/decreament;
}

Print value from 1 to 10 using while loop:

program:

#include< iostream>
using namespace std;
int main()
{
int i;
i=1;
while(i<=10){
cout<< i;
i++;
}
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 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!