0
What is the difference between x++ and ++x?
3 Answers
+ 4
They both increase the value of x, but x++ first use the value, and ++x first increase. For example,
x=0;
y=x++; // y=0, x=1
z=++y; // z=1, y=1
+ 3
post increment and x++
pretty increment ++x
+ 3
If you do:
int x = 5;
And then output x++, it will output 5 then increment x.
If you output ++x, it will increment x and then output 6.