Calculations

Name Operator Examples Result
Addition + 1 + 3 4
2 + 4 6
3.5 + 2.4 5.9
Concatenation . 'Awe' . 'some' Awesome
'3' . '5' 35
10 . ' cats' 10 cats
Subtraction - 5 - 3 2
2 - 2 0
3 - 5 -2
Multiplication * 2 * 2 4
3 * 5 15
3 * 0 0
Division / 10 / 2 5
0 / 3 0
5 / 0 INF
Remainder Of Division % 10 % 2 0
4 % 3 1
17 % 6 5

Explanation for Remainder Of Division

division-remainder

Let's start with a program that prints rectangle's area by knowing it's width and height.

Output:

Explanation

  • At line 6 width and height are multiplied (via * operator).
  • At line 7 string and number are concatenated via . operator.

Let's demonstrate the rest of the operators:

Output: