0
Please help me i cant understand the difference between x++ and ++x
I did not understand
4 Réponses
+ 2
x++ means use then change while ++x means change then use
+ 1
thanks this was very helpefull
0
x++ wil plus 1 after use
++x will plus 1 before use
Example
int y=2;
int x=3;
int sum0, sum1, sum2;
sum0 = y+x // sum0 = 5
sum1 = y+(++x) // sum1= 6 at this line -> 2+(4)
sum2 = y+(x++) // sum2 = 5 at this line -> 2+(3) after this line if you use x, x will equal to 4
0
int x=5;
cout<<x++<<endl;//Output 5, then x=6
x=5;
cout<<++x<<endl;//x=6 then output 6