The arithmetic operators performs basic arithmetic operations for the given variable or value, Arithmetic operation requires minimum two variables or values (operand) to perform operation. It returns the value by performing operation. As it requires minimum two operand, it also called as binary operators.
Arithmetic Operators
1. | Addition operator |
2. | Subtraction operator |
3. | Multiplication operator |
4. | Division operator |
5. | Modulus operator |
Addition operator
An addition operator adds two variable or value provided to it. It returns the result after performing operation. If multiple operator exists in the operation, it evaluate the operation from left to right.
1 let x = 20;
2 let y = 10;
3
4 let z = x + y;
Subtraction operator
A substract operator substract right side variable or value from the left side variable or value provided to it. It returns the result after performing operation. The result can be either negative or possible depends on order in which it used. In case of multiple operator exists in the expression, it evaluate expression from left to right.
1 let x = 30;
2 let y = 15;
3
4 let z = x - y;
Multiplication operator
A multiplication operator multiplies either side of variable or value with other one. It returns the result after performing operation. If multiple operator specified in the expression, it evaluate the operation by multiplying from left to right.
1 let x = 5;
2 let y = 4;
3
4 let z = x * y;
Division operator
The division operator divide left side operand with right side operand. It returns the result after performing operation. If multiple operator specified in the expression, it evaluate the operation by dividing from left to right. In case right side operand is zero, it returns Infinite from the operation.
1 let x = 25;
2 let y = 5;
3
4 let z = x / y;
Modulus operator
A modulus operator divides left side operand by right side operand. It return the result as remainder value which less then or zero from the right side operand. If multiple operator specified in the expression, it evaluate the operation from left to right, a left side operators evaluates first.
1 let x = 9;
2 let y = 5;
3
4 let z = x % y;
5
Related options for your search