0
i don't understand prefix and postfix.. help me??
6 Answers
+ 2
This has been asked before. https://www.sololearn.com/Discuss/123619/?ref=app
+ 2
You're a bit backwards on it.
++a == 7
a++ == 6
Assuming that a is 6.
+ 1
With prefix (++a) you do the incrementing first and then return the final value. So if a was 6 then ++a returns 7.
With postfix (a++) you return the current value and then increment. So if a was 6 then a++ returns 6 but if you checked the value of a again after it would be 7.
Think of it this way, prefix the ++ comes first so you add then return a. When the ++ comes second you return a then increment (postfix).
0
if a = 6 then,
++a = 6,
a++ = 7
is this right
0
can you explain in details..
0
thanks a lot durand,,,