Bird
0
0

What is the output of this C code?

medium📝 Predict Output Q13 of 15
C - onditional Statements

What is the output of this C code?

int x = 5, y = 8;
if (x > 0) {
    if (y < 10) {
        printf("A\n");
    } else {
        printf("B\n");
    }
} else {
    printf("C\n");
}
AA
BB
CC
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate outer if condition

    x = 5, which is greater than 0, so the outer if block runs.
  2. Step 2: Evaluate inner if condition

    y = 8, which is less than 10, so the inner if block runs and prints "A".
  3. Final Answer:

    A -> Option A
  4. Quick Check:

    x > 0 and y < 10 prints A [OK]
Quick Trick: Check outer condition first, then inner [OK]
Common Mistakes:
  • Ignoring inner condition
  • Confusing else blocks
  • Assuming no output if outer condition true

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes