+ 1

What's the best way to understand nested loops !?!?

I'm just trying to bang my head with it but no hope of understanding it !?!

7th Jun 2020, 12:46 PM
Ankith M Kashyap
Ankith M Kashyap - avatar
4 Antworten
+ 2
So for those of you having trouble in understanding give this video a try !! Link : https://youtu.be/H7frvcAHXps
7th Jun 2020, 3:34 PM
Ankith M Kashyap
Ankith M Kashyap - avatar
+ 2
Just look up to the sky! :) Because whole universe is all about nested loops: the sun is performing a loop around the Milky-way, while the earth is performing another loop around the sun, while the moon is performing another one around the earth. I bet the Milky-way may be in another galaxy's loop. The list goes on.. Take them as all 'for loops' for instance. Video contents about space and planet intervals would be much helpful.
7th Jun 2020, 9:30 PM
Mustafa Safa Soydan
Mustafa Safa Soydan - avatar
+ 1
For 2D loops it might help if you think the loops as tables. This loop: for (int i = 0: i < 10; i++) { for (int j = 0; j < 5; j++) { } } Could be thought like this: 0 1 2 ... 4 j 0 0&0 0&1 0&2 0&4 1 1&0 1&1 1&2 1&4 2 2&0 2&1 2&2 2&4 ... 9 9&0 9&1 9&2 9&4 i This might also help if you are supposed to print triangles and other polygons, but if you are using more nested loops this might not help
7th Jun 2020, 1:37 PM
Seb TheS
Seb TheS - avatar