What if you need to solve something like this:
3 * 5 - 2?
<?php print_r(3 * 5 - 2);
<?php print_r(2 * 4 * 5 * 10);
As you see, operations can be combined. This allows us to calculate more and more complex expressions. Such property is called composition. Composition of arithmetic operations in programming is identical to that you learned in school. As you will find out later, the operation composition applies to all operations, not just arithmetic ones.
Write a program that calculates the result of
8 / 2 + 5 - -3 / 2. Do not calculate anything by hand, all the calculations must be done by your code.
Note that the interpreter does the calculations in the correct order: division and multiplication first, and only then addition and subtraction. Sometimes we need to modify this order, and we’ll talk about how to do it later.
Please sign in with your GitHub account, this is necessary to track the progress of the lessons. If you do not have an account yet, now is the time to create an account on GitHub.