0

How does a for inside a for work i kind of get confused when i work with 2 for

can someone help

28th Dec 2017, 7:10 PM
Anesti Andoni
Anesti Andoni - avatar
5 Respuestas
0
when i get stuck is for exp number 1-2-3-4-5-6now it ask the sum of 34 how do i that ?
28th Dec 2017, 11:43 PM
Anesti Andoni
Anesti Andoni - avatar
+ 5
lets say the outer loop runs 5 times printing "#" and the inner loop prints "&" 10 times you will get this patten # <outer loop &&&&&&&&&& <inner loop # <outer loop &&&&&&&&&& <inner loop # <outer loop &&&&&&&&&& <inner loop # <outer loop &&&&&&&&&& <inner loop # <outer loop &&&&&&&&&& <inner loop the outer loop complete 1 loop for every time the inner loop fully completes its loops
29th Dec 2017, 12:28 AM
D_Stark
D_Stark - avatar
+ 2
Mabye this could help you: Imagine the one for-loop that is executed 3 times. And a secend one inside the first which runs 5 times. The first one prints always A per execution. The secend B. This looks like this. A B B B B B A B B B B B A B B B B B I hope this helped.
28th Dec 2017, 7:19 PM
Viereck
Viereck - avatar
+ 1
thank you now i get it
29th Dec 2017, 12:41 AM
Anesti Andoni
Anesti Andoni - avatar
+ 1
your welcome ☺
29th Dec 2017, 1:06 AM
D_Stark
D_Stark - avatar