Arithmetic Operators
A typical arithmetic operation operates on two numbers.
Adding
The addition operator (+) adds numbers:
let x = 5;
let y = 2;
let z = x + y;
\Output 7
Subtracting
The subtraction operator (-) subtracts numbers.
let x = 5;
let y = 2;
let z = x - y;
\Output 3
Multiplying
The multiplication operator (*) multiplies numbers.
let x = 5;
let y = 2;
let z = x * y;
\Output 10
Dividing
The division operator (/) divides numbers.
let x = 5;
let y = 2;
Console.lof("x / y");
\Output 2
Remainder
The modulus operator (%) returns the division remainder.
let x = 5;
let y = 2;
Let z =x%y;
\Output 1
Incrementing
The increment operator (++) increments numbers.
let x = 5;
x++;
let z = x;
\Output 6
Decrementing
The decrement operator (--) decrements numbers.
let x = 5;
x--;
let z = x;
\Output 4
Top comments (0)