Arithmetic Operators
- Addition (+): Adds two values together
- Subtraction (-): Subtracts one value from another
- Division (/): Divides one value by another
- Multiplication (*): Multiplies two values together
- Exponentiation (^): Raises a number to a power
- Modulo (MOD): Returns the remainder of a division operation
- Integer Division (DIV): Returns the whole number of a division operation
Pseudocode example:
a ← 5
b ← 3
c ← a + b
d ← a - b
e ← a * b
f ← a / b
g ← a MOD b
h ← a ^ b
i ← a DIV b
Python example:
a = 5
b = 3
c = a + b
d = a - b
e = a * b
f = a / b
g = a % b
h = a ** b
i = a // b
Java example:
int a = 5;
int b = 3;
int c = a + b;
int d = a - b;
int e = a * b;
double f = (double) a / b;
int g = a % b;
double h = Math.pow(a, b);
int i = a / b;
Visual Basic example:
Dim a As Integer = 5
Dim b As Integer = 3
Dim c As Integer = a + b
Dim d As Integer = a - b
Dim e As Integer = a * b
Dim f As Double = a / b
Dim g As Integer = a Mod b
Dim h As Double = Math.Pow(a, b)
Dim i As Integer = a \ b