9th Feb 2019, 1:52 AM
Saleem
Saleem - avatar
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
9th Feb 2019, 2:13 AM
Lambda_Driver
Lambda_Driver - avatar
+ 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
9th Feb 2019, 2:13 AM
Elghozi Nasreddine
Elghozi Nasreddine - avatar
+ 1
Ghozzi Nassreddine This question was in exam thats why i can not change the code. they asked for ouput
9th Feb 2019, 3:27 AM
Saleem
Saleem - avatar
+ 1
None i changed the code to understand the reason of the result you get.
9th Feb 2019, 1:54 PM
Elghozi Nasreddine
Elghozi Nasreddine - avatar
+ 1
Thanks a lot for your time sir
9th Feb 2019, 2:00 PM
Saleem
Saleem - avatar