Recall & Review
beginner
What is operator precedence in C?
Operator precedence determines the order in which operators are evaluated in an expression. Operators with higher precedence are evaluated before those with lower precedence.
Click to reveal answer
beginner
Which operator has higher precedence:
* (multiplication) or + (addition)?The multiplication operator
* has higher precedence than the addition operator +. So, in 3 + 4 * 5, the multiplication happens first.Click to reveal answer
intermediate
What does associativity mean in operator precedence?
Associativity defines the direction in which operators of the same precedence are evaluated. For example, left-to-right means operators are evaluated from left to right.
Click to reveal answer
beginner
How does parentheses
( ) affect operator precedence?Parentheses have the highest precedence. Expressions inside parentheses are evaluated first, no matter what other operators are present.
Click to reveal answer
beginner
In the expression
a = b + c * d;, which operation happens first?The multiplication
c * d happens first because * has higher precedence than +. Then the result is added to b, and finally assigned to a.Click to reveal answer
Which operator has the highest precedence in C?
✗ Incorrect
Parentheses have the highest precedence and force the expression inside them to be evaluated first.
What is the associativity of the subtraction operator (-) in C?
✗ Incorrect
Subtraction has left-to-right associativity, so expressions like 10 - 5 - 2 are evaluated as (10 - 5) - 2.
In the expression
5 + 3 * 2, what is the result?✗ Incorrect
Multiplication happens first: 3 * 2 = 6, then addition: 5 + 6 = 11.
Which operator has lower precedence than multiplication (*)?
✗ Incorrect
Addition (+) has lower precedence than multiplication (*), division (/), and modulo (%).
What happens first in
a = (b + c) * d;?✗ Incorrect
Parentheses force the addition (b + c) to happen before multiplication.
Explain operator precedence and how it affects the evaluation of expressions in C.
Think about which operations happen first in a math expression.
You got /3 concepts.
Describe the role of parentheses in changing operator precedence.
How do parentheses help control the order of operations?
You got /3 concepts.