Let i = 5
Definition of post increment is – Use the value first and then change it.
so here i = i++; will first use the value 5, after that i value of i will get changed to 6. But the previous value of i=5 will overrite the value 6. Hence we will get i=5.
But if we use the statement
j = i++;
Here i’s previous value 5 gets stored in the variable j after the increement of i to 6. Hence j=5 and i=6