Arithmetic Logical Relational-operatorsCONT
Arithmetic Logical Relational-operatorsCONT
ANd Relational
Operators
WHAT IS OPERATOR?
2
INPUT OPERATOR OUTPUT
3
1
ARITHMETIC OPERATORS
Computer programs are widely used
for mathematical calculations. We can
write a computer program which can
do simple calculation like adding two
n u m bers a n d w e ca n a lso w r i t e a
program, which can solve a complex
equation.
5
ARITHMETIC OPERATORS IN JAVASCRIPT
6
Adding
The addition operator (+) adds numbers.
Example:
let x = 5;
let y = 2;
let z = x + y;
7
Subtracting
The subtraction operator (-) subtracts
numbers.
Example:
let x = 5;
let y = 2;
let z = x - y;
8
multiplying
The multiplication operator (*) multiples
numbers.
Example:
let x = 5;
let y = 2;
let z = x*y;
9
dividing
The division operator (/) divides numbers.
Example:
let x = 5;
let y = 2;
let z = x / y;
10
remainder
The modulus operator (%) returns the
division remainder.
Example:
let x = 5;
let y = 2;
let z = x % y;
11
incrementing
The increment operator (++) increments
numbers.
Example:
let x = 5;
x++;
let z = x;
12
decrementing
The decrement operator (--) decrements
numbers.
Example:
let x = 5;
x--;
let z = x;
13
exponentiation
The exponentiation operator (**) raises the
first operand to the power of the second
operand.
Example:
let x = 5;
let z = x ** 2;
14
exponentiation
The exponentiation operator (**) raises the
first operand to the power of the second
operand.
Example:
let x = 5;
let z = x ** 2;
15
operator precedence
Operator precedence describes the order
in which operations are performed in an
arithmetic expression.
let x = 100 + 5 * 3;
16
ASSIGNMENT OPERATORS
Are operators that assign a value to a
variable.
19
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
20
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
21
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
22
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
23
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
24
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
25
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
4. Use the correct assignment operator that will
result in x being 15 (same as x = x + y)
x=10;
y=5;
x =+ y;
26
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
4. Use the correct assignment operator that will
result in x being 15 (same as x = x + y)
x=10;
y=5;
x =+ y;
27
ACTIVITY 1:
Indicate the correct arithmetic operators in
each statement.
30
LOGICAL OPERATORS
31
In two or three columns
32
Example
let x = 1;
if (x > 0) alert( 'Greater than zero!' );
let hour = 9;
if (hour < 10 || hour > 18) {
alert( 'The office is closed.' );
}
33
Example
let x = 1;
if (x > 0) alert( 'Greater than zero!' );
let hour = 9;
if (hour < 10 || hour > 18) {
alert( 'The office is closed.' );
}
34
RELATIONAL OPERATORS
They allow us to
compare numeric and
char values to
determine if one is
greater than, less than,
equal to, or not equal
to another.
35
RELATIONAL OPERATORS
36
RELATIONAL OPERATORS
37
COMPARISON OPERATORS
38