It's all about how you have ++ x / ++ y in the if check. Follow the logic:
x = 0 y = 0 z = 0
Then you get into the if line, since ++ x is 1, it is not> 2, so it launches the ++ y part, which is y = 1, if the result is false, and your values โโnow:
x = 1 y = 1 z = 0
iteration 2 is performed, with z = 1 Then you get into the if line, since ++ x is 2, not> 2, so it starts the ++ y part, which is y = 2, if the result is false, and your values โโare now :
x = 2 y = 2 z = 1
iteration 3 is executed, with z = 2 Then you get to the if line, since ++ x is 3, this is> 2, so x ++ does (does x = 4), ++ y is NOT executed because OR was true in if. Now the values โโare:
x = 4, y = 2, z = 2
Repeat this until z = 5 and you get x = 8, y = 2
Michael
source share