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;
}
1
2
3
4
5
6
7
8
9
10