For loop is also
use for repetition. In for loop we
initialize the object, use condition and increment operator in one small
brackets with the keyword for. You
can see the code and understand the use of for
loop in right way.
Code:
#include <iostream>
using namespace std;
int main()
{
int i;
for(i=0;i<=20;i++)
{
cout<<i<<endl;
}
}
Output:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0 Comments