0
A++ and --A
if A++ is like A = A + 1 then whats --A?
2 Answers
+ 1
--a is pre decrement. It will decrease value of a by 1.
+ 1
You have to differentiate between post and pre increment. These 2 have different meanings.
For Pre :
++a // means a=a+1
--a // means a=a-1
For post :
a++ // a=a+1
a-- // a=a-1
The difference between pre and post is the order of execution.
Pre first de/increases its value then continues the normal order.
post first calculates its current calculation with the current value. Then de/increases the variable by one. Then continues with the normal order.