Page 88 - CA_Blue( J )_Class9
P. 88
Write a program to input two numbers and perform the following unary operation:
Program 2
c = a++ * ++b.
1 class unary_operator
2 {
3 public static void main(int a, int b)
4 {
5 int c;
6 c = a++ * ++b;
7 System.out.println("Result "+c);
8 }
9 }
Input: You will get the following output:
Here 'a' has postfix increment operator '++' and 'b' has prefix decrement operator '--'.
5.2.2 Binary Operator
An operator that works with two operands is called binary operator. For example, a+b, a/b.
Where, a and b is the operands, + and -; are the operators.
Program 3 Write a program to input two numbers and print the product and difference.
1 class binary_operator
2 {
3 public static void main(int a, int b)
4 {
5 int p,d;
6 p=a*b;
7 d=a-b;
8 System.out.println("Product "+p);
9 System.out.println("Difference "+d);
10 }
11 }
86 Touchpad Computer Applications-IX

