Page 60 - CA_Blue( J )_Class10
P. 60
Addition (+) Operator
The addition (+) operator is used for adding two values or operands either of integer literals or real literals. The result
may be positive or negative depending on the values.
Subtraction (-) Operator
The subtraction (-) operator is used for finding the difference between two values or operands either of integer literals
or real literals. The result of the subtraction operator may be positive or negative depending on the values.
Multiplication (*) Operator
The multiplication (*) operator is used for multiplying two values or operands either of integer literals or real literals.
The result of the multiplication operator may be positive or negative depending on the values.
Division (/) Operator
The division (/) operator is used for finding the quotient between two values or operands either of integer literals or
real literals. The result of the division operator may be positive or negative depending on the values.
Modulus (%) Operator
The modulus (%) operator is used for finding the remainder between two values or operands either of the integer
literals or real literals. It is also known as remainder operator. The result of the modulus operator may be positive or
negative depending on the values.
class ArithmeticDemo {
public static void main (String[] args) {
int result = 1 + 2;
// result is now 3
System.out.println("1 + 2 = " + result);
int original_result = result;
result = result - 1;
// result is now 2
System.out.println(original_result + " - 1 = " + result);
original_result = result;
result = result * 2;
// result is now 4
System.out.println(original_result + " * 2 = " + result);
original_result = result;
result = result / 2;
// result is now 2
System.out.println(original_result + " / 2 = " + result);
original_result = result;
result = result + 8;
// result is now 10
5858 Touchpad Computer Applications-X

