Increment and Decrement Operator:
Both the increment and decrement operators can either precede (prefix) or follow (postfix) the operand.
pre-increment:
++number
post-increment:
number++
pre-decrement:
--number
post-decrement:
number--
Difference between pre and post Increment/Decrement Operator:
- When an increment or decrement is used as part of an expression, there is an important difference in prefix and postfix forms.
- If you are using prefix form then increment or decrement will be done before rest of the expression
- and if you are using postfix form, then increment or decrement will be done after the complete expression is evaluated
Increment and Decrement Floating-Point Variables:
- You can also apply the prefix and postfix increment and decrement operators, ++ and --, to a floating-point variable with essentially the same effect as for an integer;
- The variable will be incremented or decremented by 1.0.
0 Comments