posted 18 years ago
OK, you have your do-while loop that only checks after it runs the for loop.
(A) The for loop counts, since the post incrementer is on the boolean expression,
(B)the check is first i = 0 and it is less than 2,
(C) now increment it to 1.
(D) Print 1,
(E) now i=1 and it is less than 2,
(F) now increment it to 2.
(G) Print 2.
(H) now i=2 and it is not less than 2, so drop out of the for loop.
(I) evaluate the while j = 0 and it is less than 2, now increment j to 1 and go back to (A).
Now in (I) when j=2 then it does not go back to (A) anymore and the program is done.
Mark