Operators and Operands

The numbers (in an arithmetic operation) are called operands. The operation (to be performed between the two operands) is defined by an operator.

Operand Operator Operand
100 + 50

Adding: The addition operator (+) adds operands:   var x = 5, y = 2, z = x + y;   (The value of z is 7)
Subtracting: The subtraction operator (-) subtracts operands:  var x = 5, y = 2, z = x - y;   (The value of z is 3)
Multiplying: The multiplication operator (*) multiplies operands:  var x = 5, y = 2, z = x * y;   (The value of z is 10)
Dividing: The division operator (/) divides operands:  var x = 5, y = 2, z = x / y;   (The value of z is 2.5)


Modulus: The modular operator (%) returns the remainder from the division of operands:  var x = 5, y = 2, z = x % y;   (The value of z is 1)
In computing, the modulo operation (called modulus) finds the remainder after division of one operand by another. In this case, 5 ÷ 2 = 2 with 1 remaining as the leftover.


Incrementing: The increment operator (++) increments operands:
  var x = 5;
  x++;
  var z = x;
   (The value of z is 6)
The increment operator increments (adds 1 to) its operand and returns a value.


Decrementing: The decrement operator (--) decrements operands:
  var x = 5;
  x--;
  var z = x;
   (The value of z is 4)
The decrement operator decrements (subtracts 1 from) its operand and returns a value.

Back Table of Contents Next