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