Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q5 of 15
C - Operators and Expressions
What will be the output of this code snippet?
int i = 5;
int j = i-- + ++i;
printf("%d", j);
A11
B9
C10
D12
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate i-- and ++i values

    i-- uses 5 then decrements to 4; ++i increments 4 to 5 and uses 5.
  2. Step 2: Calculate sum

    Sum is 5 (from i--) + 5 (from ++i) = 10.
  3. Final Answer:

    10 -> Option C
  4. Quick Check:

    Post-decrement uses old value; pre-increment uses incremented value [OK]
Quick Trick: Post-decrement uses old value; pre-increment uses new value [OK]
Common Mistakes:
  • Mixing values of i before and after increments
  • Assuming increments happen simultaneously
  • Ignoring operator side effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes