How would you explain a nested FOR loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How would you explain a nested FOR loop?

25th Dec 2016, 10:43 PM
Didi Georgel Danaila
Didi Georgel Danaila - avatar
2 Answers
+ 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
25th Dec 2016, 11:40 PM
Andreas K
Andreas K - avatar
+ 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\/
26th Dec 2016, 9:58 PM
Usman khan
Usman khan - avatar