Bird
0
0

Why does the expression int x = 2 + 3 * 4 / 6 - 1; produce the value 3 in C?

hard📝 Conceptual Q10 of 15
C - Operators and Expressions
Why does the expression int x = 2 + 3 * 4 / 6 - 1; produce the value 3 in C?
ABecause addition is evaluated before multiplication
BBecause division has the lowest precedence
CBecause multiplication and division are evaluated before addition and subtraction
DBecause subtraction is evaluated before addition
Step-by-Step Solution
Solution:
  1. Step 1: Apply operator precedence rules

    Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).
  2. Step 2: Evaluate expression stepwise

    3 * 4 = 12, then 12 / 6 = 2, then 2 + 2 - 1 = 3.
  3. Final Answer:

    Multiplication and division evaluated before addition and subtraction -> Option C
  4. Quick Check:

    Operator precedence explains result = Because multiplication and division are evaluated before addition and subtraction [OK]
Quick Trick: Multiply/divide before add/subtract to get correct result [OK]
Common Mistakes:
  • Assuming addition before multiplication
  • Thinking division is lowest precedence
  • Confusing subtraction order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes