Bird
0
0

What will be printed by this C code?

medium📝 Predict Output Q4 of 15
C - onditional Statements
What will be printed by this C code?
int val = 3;
if (val >= 5) {
    printf("High\n");
} else {
    printf("Low\n");
}
ALow
BHigh
CNo output
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the condition

    Check if val (3) is greater than or equal to 5. It is not.
  2. Step 2: Determine which block runs

    Since condition is false, the else block executes.
  3. Final Answer:

    Low -> Option A
  4. Quick Check:

    3 < 5 triggers else block [OK]
Quick Trick: False condition runs else block [OK]
Common Mistakes:
  • Assuming condition is true without checking
  • Confusing >= with >
  • Expecting no output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes