Bird
0
0

What will be the output of this C code?

medium📝 Predict Output Q13 of 15
C - onditional Statements
What will be the output of this C code?
#include 
int main() {
    int x = 10;
    if (x > 5) {
        printf("Greater\n");
    } else {
        printf("Smaller\n");
    }
    return 0;
}
AGreater
BSmaller
C10
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the condition x > 5

    Variable x is 10, which is greater than 5, so the condition is true.
  2. Step 2: Determine which block runs

    Since the condition is true, the code inside the if block runs, printing "Greater".
  3. Final Answer:

    Greater -> Option A
  4. Quick Check:

    10 > 5 is true, so prints "Greater" [OK]
Quick Trick: Check if condition is true or false to pick output [OK]
Common Mistakes:
  • Confusing which block runs on true condition
  • Ignoring the newline character in printf
  • Assuming else block runs when condition is true

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes