The difference between pre-increment (++a) and the post-increment (a++) shows up only when you use the value of the expression. In both of the above statements, the increment of I occurs, but the value of the expression is thrown away, and is not stored or printed or passed anywhere. But if you capture and use the value of the expression, you will observe the difference in behavior.
Following Example:-
a = 1; s = ++a; (a is 2, s is 2)
Another are:-
a = 1; s = a++; (a is 2, s is 1)
Question and answer is powered by AnsPress.io