Arithmetic operators
Introduction
An arithmetic operator in programming is one which performs maths on numbers.
Common maths arithmetic operators
There are a six arithmetic operators you should cwertainly be aware of, although their are others.
+ plus. For example, 5 + 6 = 11
- minus. For example, 20 - 5 = 15
* multiplication. For example, 4 * 3 = 12
/ division. For example, 16 / 4 = 4
MOD is the remainder. For example:
-
-
- 10 MOD 6 = 4
- 21 MOD 4 = 1
- 8 MOD 2 = 0.
-
It is the remainder after you have divided the second number into the first.
DIV is integer divison. for example:
-
-
- 10 DIV 2 = 5
- 14 DIV 3 = 4
- 20 DIV 7 = 2
-
This is the number of times the second number will completely go into the first number.