Arithmetic Operators
- Addition (+): adds two or more numbers together, e.g.
2 + 3 equals 5.
- Subtraction (-): subtracts one number from another, e.g.
5 - 3 equals 2.
- Multiplication (*): multiplies two or more numbers together, e.g.
4 * 5 equals 20.
- Division (/): divides one number by another, e.g.
10 / 2 equals 5.
- Modulus (%): finds the remainder of a division operation, e.g.
17 % 5 equals 2.
Comparison Operators
- Equal to (==): checks if two values are equal, e.g.
5 == 5 is true.
- Not equal to (!=): checks if two values are not equal, e.g.
5 != 3 is true.
- Less than (<) and greater than (>): compare two values, e.g.
3 < 5 and 5 > 3 are both true.
- Less than or equal to (<=) and greater than or equal to (>=): e.g.
3 <= 5 and 5 >= 3 are both true.
Logical Operators
- And (&&): checks if two conditions are both true, e.g.
true && true is true.
- Or (||): checks if either of two conditions is true, e.g.
true || false is true.
- Not (!): reverses the truth value of a condition, e.g.
!true is false.