for loop

hi
in this code, output is 3 5 7 11
i=1 and j Uninitialized. Why is this output??

 
Last edited on
Iteration 1:
i = 1
j = (7 && i < 10) = (true && true) = 1
j++ + ++i = 1 + 2 = 3
(i = 2, j = 2)

Iteration 2:
i = 3
j = (7 && i < 10) = 1
j++ + ++i = 1 + 4 = 5
(i = 4, j = 2)

Iteration 3:
i = 5
j = (7 && i < 10) = 1
j++ + ++i = 1 + 6 = 7
(i = 6, j = 2)

Iteration 4:
i = 7
j = (7 && i < 10) = 1
j++ + ++i = 1 + 8 = 9
(i = 8, j = 2)

Iteration 5:
i = 9
j = (7 && i < 10) = 1
j++ + ++i = 1 + 10 = 11
(i = 10, j = 2)

Iteration 5:
i = 10
j = (7 && i < 10) = false → loop terminated
Topic archived. No new replies allowed.