The best way to understand what is going on is to step through the code. Either step through with a debugger (Borland, Microsoft and GNU compilers all have a debugger that can show you what is going on in the code and let you step one line at a time).

If you don't want to use a debugger, you can also "pretend to be the computer" and "execute" one line of code at a time, just like you expect the machine to do it. Write down what the result is, taking special care about the first and last operatons in your loop.

--
Mats