This is a question from kn king\'s c programming : a modern approach. I can\'t understand the solution given by him:-
The expression ++i is equivalent to (i
i = 10
printf("%d", i++);
will print 10, where as
printf("%d", ++i);
will print 11
X = i++ can be thought as this
X = i
i = i + 1
where as X = ++i is
i = i + 1
X = i
so,
printf ("%d", ++i);
is same as
printf ("%d", i += 1);
but not
printf ("%d", i++);
although value of i after any of these three statements will be the same.