Page 62 - CA_Blue( J )_Class10
P. 62
• If double i = -20.5 then
i++ = -20.5 // (if printed in same line)
Unary Decrement (--) Operator
The unary decrement (--) operator works only on one operand. The original value of the variable is decreased by 1 after
the execution of this operator. It can work only on variables and identifiers which may either contain an integer literal
or a real literal. The result of the decrement operator may be positive or negative.
For examples:
• If int a = 20 and b = 4 then
--a = 19
b-- = 3 // (if printed in next line)
Hence, the output is same as a = a - 1 or b = b -1.
• If int i = -20 then
--i = -21
• If int i = -20.5 then
i-- = -20.5 // (if printed in same line)
i--=-19.5 // (if printed in next line)
Program 2: To use all the arithmetic operators.
You will get the following output:
The unary increment and decrement operators are used in two forms which are prefix and postfix.
6060 Touchpad Computer Applications-X

