Ida Achi wrote:
Well,
First iteration of outer loop
j's value = 0
The inner loop will print 0 then the last condition is met that if j ==0 break from this inner loop, so at this point
0
j increments to 1
Enters inner loop and executes normally for 3 times , as there is no condition met to break from the inner loop
so at this point output would be
0 1 1 1
j increments to 2
The inner loop executes normally for one times, but at the second iteration as this condition is encountered
As compiler sees, value of j was 2 so this condition evaluates to true and before the third iteration, the loop terminates.
At this stage, output is
0 1 1 1 2
outer loop third iteration
j=3
Enters the inner loop and prints out the value of j one time, same on second iteration as well, now at sametime after
printing value of j the second time see the state of variables and condition
j=3 and k= 1
so this condition which is given as
evaluates to true and terminates the outer most loop as well.
At this stage the output is
0 1 1 1 2 3 3
Hope this helps,