What is the difference between pre-increment and post-increment in the cycle (for/while)?

Since the statement i++ ends at the ; in your example, it makes no difference whether you use pre- or post-increment.

The difference arises when you utilize the result:

int j = i++; // i will contain i_old + 1, j will contain the i_old.

Vs:

int j = ++i; // i and j will both contain i_old + 1.

Leave a Comment