0
How does a for inside a for work i kind of get confused when i work with 2 for
can someone help
5 odpowiedzi
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 ?
+ 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
+ 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.
+ 1
thank you now i get it
+ 1
your welcome ☺