On line 20: after the statement is done x=8 y=8 z=16 One line21: x and y are still 8 so z=16, then x and y get a post increment x=9 y=9 You never do anything with the new values of x and y so z stays at 16 The code you are showing is a good learning tool but you would never want to mix up pre and post increments because its too confusing. Its much better to be more explicit with what you want to happen. z=x+y; x++; y++; Of course people will have different opinions.