0

can any one explain about prefix and postfix operators completely with an example ?

12th Feb 2017, 2:46 AM
RAHUL VARMA
RAHUL VARMA - avatar
2 odpowiedzi
+ 12
@Gordie | Oh, I actually didn't know that. Thanks, sorry!
10th Dec 2017, 9:36 AM
Tamra
Tamra - avatar
+ 11
People ask this a lot...there's a similar question like 10 posts down. I'll explain anyway. Prefix (++x, --x) has high priority/precedence, and adds/removes 1 from the variable first and foremost. Other math and operations are done next. Ex: y = ++x; //Adds 1 to x, then assigns x to y. Postfix (x++, x--) has low priority. After all other operations are done, 1 is added/removed from the variable. Ex: y = x++; //Assigns the old value of x to y, then adds 1.
12th Feb 2017, 3:29 AM
Tamra
Tamra - avatar