Nested loop in C++ by R4R Team

There are three type of loop in C or C++ language:
-for loop
-while loop
-do while loop

What is nested loop?
Loop inside another loop is known as nested loop.

Example-
Traversal of two-dimensional array or matrix.

progran to display number from 1 to 25 using nested loop

program:

#include

using namespace std;

int main()
{
int i,j,value=1;
for(i=1;i<=5;i++){
for(j=1;j<=5;j++){
cout<< value<<" ";
value++;
}
}
return 0;
}


output-

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

-In this program, we start value from 1 and increase in each iteration.




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!