For loop in C++ by R4R Team

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


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 for 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!