+ 1
What defferent between x++ ++x and x-- --x
3 Respostas
+ 6
an example with cout is clearer:
int x = 1,y = 1;
cout x++; // outputs 1 then increments x by 1
cout ++y; // increments y by 1 then outputs 2
+ 3
++x increments the value of x and then returns x
x++ returns the value of x and then increments
example: x= 0 ;
a=++x;
b=x++;
after the code is run both a and b will be 1 but x will be 2.h
+ 2
x++ means display and then update
++x means update and then display
for example ;
say x=3;
so if you do x++ ;
it shows the output 3 and then updates its value to 4 whereas for ++x;
it first updates to 4 and then displays 4;