Math Operators โ๏ธ#
C supports the addition, subtraction, multiplication, and division operations from math. Hereโs a list of operators and example usage.
Name |
Symbol |
Description |
Example |
---|---|---|---|
Addition |
|
Adds two numbers together |
|
Subtraction |
|
Adds two numbers together |
|
Multiplication |
|
Multiplies two numbers together |
|
Division |
|
Divides the first number by the second number |
|
Caution
Just like in regular math, you cannot divide by zero. If you do then your program may behave unexpectedly!
Tasks ๐ฏ#
What does 5 * 2
evaluate to?
Solution โ
5 * 2 = 10
What does 5 / 0
evaluate to?
Solution โ
This isnโt defined, because you cannot divide by zero.