What is the different between ++X and X++ (Prefix and Postfix Increment )
a) Function of ++X and X++
++X
- Increment X value then Execute
X++
- Execute old X value then Increment
b)
We need both of the increment type depend on the need of our logic.
Postfix Increment will be useful if we want to make use of old value in our execution before we increment it.
Prefix Increment Is useful when we need the increment value right away in our execution.
No comments:
Post a Comment