0
0
Cprogramming~5 mins

Operator precedence - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AParentheses ( )
BAddition (+)
CAssignment (=)
DLogical AND (&&)
What is the associativity of the subtraction operator (-) in C?
ALeft to right
BNo associativity
CRight to left
DDepends on compiler
In the expression 5 + 3 * 2, what is the result?
A13
B16
C10
D11
Which operator has lower precedence than multiplication (*)?
ADivision (/)
BAddition (+)
CModulo (%)
DUnary minus (-)
What happens first in a = (b + c) * d;?
AMultiplication
BAssignment
CAddition inside parentheses
DEvaluation from right to left
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.