Checkpoint 2.8.1.
- (6*4)+1
- 25
- 6*(4+1)
- 30
- (6/4)+1
- 2
- 6/(4+1)
- 1
Match the expression to its correct output. Don’t forget to consider integer division!
Try again!
2 * 3 - 1
yields 5, not 4, and 2 / 3 - 1
yields -1, not 1 (remember that in integer division 2/3
is 0).
minute * 100 / 60
, the multiplication happens first, yielding 5900 / 60
, which in turn yields 98. If the operations had gone from right to left, the result would be 59 * 1 which is 59, which is wrong.
2 * (3 - 1) is 4
. You can also use parentheses to make an expression easier to read, as in (minute * 100) / 60
, even though it doesn’t change the result.
1 + 5
is the only operation remaining. I’m not going to ask you any questions about it. However, it’s important that you can wrap you head around the fact that the +
operator appeared first in the calculation, but it was the last operator to be evaluated. The order of operations can be kind of confusing at times, but I think you’ve got a good grasp of the concept!