0
How would you explain a nested FOR loop?
2 Respuestas
+ 1
a nested for loop is like going through a table. First you go through the first row, then the second, the third and so on...
So the outer FOR Loop goes through each row and the inner FOR loop goes inside each row through each column
+ 1
A loop containing another loop in its loop-body is called Neated for loop.
But in a nested loop ,the inner loop must terminated before the outer loop .
The following is an example of nested for loop:
:
for ( i=1 ; i <5 ; ++i) //outer loop
{
cout <<"\n";
for (j=1 ; j <=i ; ++j) //inner loop
cout <<"*"; This for loop is
within another for loop
}
HOPE this may help you.
PEACE\/