+ 2
help me to understand this code
5 Answers
+ 2
Based on the code, the values of i will be 1,2,3,4 and 5.
The final value of the inner loop will always be 10. Why? Look at the loop itself.
for (var k=6; k<=10; k=k+1)
The inner loop will only end once k == 10. Once the condition k <= 10 is satisfied, k is incremented by 1.
So k will become 7,8,9 and 10. Once k ==10, the loop stops and the statement inside the inner loop is executed before the outer loop starts again. Therefore, the final value of the inner loop will always be 10.
1*10=10
2*10=20
3*10=30
4*10=40
5*10=50
+ 2
because you are use the same index i in the nested for loop.
this what you have to do:
https://code.sololearn.com/WKu4L0w99swU/?ref=app
+ 1
Ghozzi Nassreddine This question was in exam thats why i can not change the code. they asked for ouput
+ 1
None i changed the code to understand the reason of the result you get.
+ 1
Thanks a lot for your time sir