Originally Posted by cscgal
Can someone please explain to me the difference between ++i and i++ when written as part of an expression (i.e. within loops and if statements) ? Thanks 
i++: do the calculation or do the comparison before the i's value is increment.
++i: increment the i's current value by 1 before doing the calculation or doing the comparison.
Hence, using in for loop, we cannot see clearly the differences.
However, using in if statement, they are clearly different.
For instance, we have i = 4.
if (i++ == 4) // the result is true since the current value of i is 4. After doing the comparison, then the i's value now becomes 5.
Whereas, if (++i == 4) // the result is false since the value of i is increment first, now the value of i becomes 5, then it does the comparison.
I hope it will help you.