Bird
0
0

What will be the output of the following C code?

medium📝 Predict Output Q13 of 15
C - Basics and Execution Environment
What will be the output of the following C code?
int main() {
    int a = 5;
    int b = 3;
    int c = a + b * 2;
    printf("%d", c);
    return 0;
}
A16
B13
C11
D10
Step-by-Step Solution
Solution:
  1. Step 1: Understand operator precedence in the expression

    Multiplication (*) has higher precedence than addition (+), so b * 2 is calculated first: 3 * 2 = 6.
  2. Step 2: Calculate the final value of c

    Then add a: 5 + 6 = 11.
  3. Final Answer:

    11 -> Option C
  4. Quick Check:

    5 + (3 * 2) = 11 [OK]
Quick Trick: Remember multiplication before addition in expressions [OK]
Common Mistakes:
  • Adding before multiplying
  • Confusing operator precedence
  • Misreading variable values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes