PHP: Commutative operation
We learn this in grade one: two plus three is the same as three plus two. This is one of the basic laws of arithmetics that we know intuitively. It's called a commutative property of an operation.
A binary operation is commutative if changing the order of operands doesn't affect the outcome. Obviously, addition is commutative:
3 + 2 = 2 + 3.
Is subtraction commutative? Of course not:
2 - 3 ≠ 3 - 2. Operators in programming follow the same rules.
Actually, most of the operations you'll use aren't commutative. So make you pay attention to the order of operands.
Write a program, that calculates and prints to screen results of the following mathematical expressions: "3 to the power of 5" and "-8 divided by -4".
The results will be displayed together, on a single line without any spaces between them. We'll learn how to fix this problem later.
Commutativity - property of an operation: changing the order of the operands does not change the result. E.g. addition is a commutative operation.