Bird
0
0

What will be printed by this code?

medium📝 Predict Output Q5 of 15
C - onditional Statements

What will be printed by this code?

int x = 3, y = 7;
if (x > 5) {
  if (y < 10) {
    printf("A\n");
  }
} else {
  printf("B\n");
}
AB
BA
CNo output
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate outer if condition

    x = 3 > 5 is false, so skip inner if block.
  2. Step 2: Execute outer else block

    Prints "B" because outer if is false.
  3. Final Answer:

    B -> Option A
  4. Quick Check:

    Outer false triggers else output [OK]
Quick Trick: Outer if false means else block runs [OK]
Common Mistakes:
  • Assuming inner if runs anyway
  • Expecting no output
  • Thinking compilation error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes