Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
5. Basic arithmetic in one expression
Text values


Great! Let's go a little further. Until now, our calculations have relied on using just a single operator.

Operators have the same order of precedence you learned in school: multiplication and division have higher priority than addition and subtraction. Thus, if you type 1+2*3, R will return 7 and not 9.

When in doubt, you can always use parentheses to clarify the order in which operations should be performed. For example, the following two expressions:

(65 + 87) * 2.20
65 + 87 * 2.20
will give us entirely different results. This is because calculations within parentheses are evaluated before anything else, according to the standard order of operations.


Tanya found another rule online for calculating ideal weight for females. This rule says to use the following formula:

45.5 + (0.9 * (height in cm - 152 ))

Calculate Tanya's ideal weight if you know that she is 172 cm tall. Don't forget to use parentheses where needed.