+ 7

Can some one properly explain difference between y = ++x and y = x++

12th Nov 2016, 10:04 AM
Ādïtyâ Râtân
Ādïtyâ Râtân - avatar
5 Respostas
+ 18
++x is prefix. x++ is postfix. In the case of y =++x , y will become (x+1), x will become (x+1). Which means that prefix adds the value before processing the data/command. However, in the case of y = x++ , y will become x and x will become (x+1). Which also means that postfix process the data/command first before it adds the value.
12th Nov 2016, 10:10 AM
Wen Qin
Wen Qin - avatar
+ 9
dude,consider y=1 and x=2 so when the condition is y = ++x first the computer will add 1 to the value of x and then give it to y, so the value of y becomes 3,and when there is y=x++ the value is first given to y and then 1 is added so in this condition value of y is 2. leave a like if you understood:-)
12th Nov 2016, 10:12 AM
Meet Turakhia
Meet Turakhia - avatar
+ 4
thanks guys
12th Nov 2016, 10:16 AM
Ādïtyâ Râtân
Ādïtyâ Râtân - avatar
+ 3
If we expand the operators :- a = x++ //since plus is after x so we get a = x x = x+1 while for : a = ++x (since x is later we have to assign later) x = x+1 a = x (where x is increment so tenchically a=x+1)
18th Nov 2016, 1:49 AM
Maxwell Miles
Maxwell Miles - avatar
0
for example if you take x=5 &y=6 the answer will be y=6 & y =5 ++x will increment the value by 1 with original value, but in case of x++ the value of x is given to y and then it will increment by 1
18th Nov 2016, 4:51 PM
Syamkumar Jerra
Syamkumar Jerra - avatar