Questions: Arithmetic Operators and Operator Precedence

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

What is the value of the expression `10 - 3 * 2 + 4`?

A18 — evaluated left-to-right: 10−3=7, 7*2=14, 14+4=18
B8 — multiplication first: 3*2=6, then left-to-right: 10−6+4=8
C0 — subtraction and addition cancel out after multiplying
D14 — the addition is evaluated before the subtraction due to left-to-right order
Question 2 Multiple Choice

A student writes `2 ** 3 ** 2` expecting the result `(2**3)**2 = 64`. What does the expression actually evaluate to?

A64 — exponentiation is left-associative, so 2**3 is computed first, giving 8, then 8**2 = 64
B512 — exponentiation is right-associative, so 3**2 = 9 is computed first, then 2**9 = 512
C64 — when operators are repeated, the language always picks the leftmost operation
D512 — the larger base is always evaluated first in chained exponentiation
Question 3 True / False

The expression `17 % 5` evaluates to 2.

TTrue
FFalse
Question 4 True / False

Adding parentheses to an expression in a way that reflects the order it would already be evaluated can change the result.

TTrue
FFalse
Question 5 Short Answer

Explain why operator precedence rules exist in programming languages, and what problem would arise if all operators were evaluated strictly left-to-right.

Think about your answer, then reveal below.