Page 96 - CA_Blue( J )_Class9
P. 96
4 {
5 int b= a++ + (++a);
6 System.out.println("Result of Unary increment operator is "+b);
7 }
8 }
Input: You will get the following output:
Unary Decrement (--) Operator
The unary decrement operator (--) works on a single operand and decreases its value by 1. This operator is only
applicable to variables (or identifiers) with numeric data types, usually integers, though some languages may allow
it with floating-point numbers. Like the increment operator, the decrement operator has two forms:
• Prefix Increment (++i): Decreases the value of i by 1 before using it in an expression.
• Postfix Decrement (i--): Uses the current value of i in an expression and then decreases it by 1 afterward.
If i=-20 then, = --i = -21
If i= -20.5 then, = i-- = -20.5
Program 13 Example of Unary decrement (--) Operators.
1 class unarydecrement
2 {
3 public static void main(int a)
4 {
5 int b= a-- + (--a);
6 System.out.println("Result Unary decrement operator is "+b);
7 }
8 }
Input: You will get the following output:
94 Touchpad Computer Applications-IX

