Increment/Decrement Operators
In C, we have ++ (increment) and decrement (– –) operators that increment or decrement the
variable’s value by 1. This can be done in two ways:
(a) ++ count; and – – count; (called
pre-increment
)
(b) count + +; and count – –; (called
post-increment
)
Please note here that if we use these increment/decrement operators as count++; or count
–
–
; they produce the same effect. However, also note that if you use these operators in an
expression such as
count = count++;
or count =++count;
then these two expressions will not produce the same effect. This is because in the first
expression, the value of count is assigned to count-variable (on the left-hand side) and the
count’s value will be incremented by one.
On the other hand,
Do'stlaringiz bilan baham: |