++y adds one to y, then does whatever it's told to do. So, when you go through and x is 5, y starts at 12. Then, you say to print ++y, so it adds one (now 13) and then prints as told. Then it goes through again, adds one to y at the beginning (now 14) and then repeats, adding one to y (now 15) and then prints. It then checks the if, and y is now 15, so it executes. At that point, x is 6, so it prints x=6.
0 comments:
Post a Comment