Bird
0
0

What will be printed by this code?

medium📝 Predict Output Q5 of 15
C - Operators and Expressions
What will be printed by this code?
int x = 0;
char* result = (x) ? "True" : "False";
printf("%s", result);
AFalse
BTrue
C0
DError
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the condition (x)

    Since x is 0, it is considered false in C.
  2. Step 2: Choose string based on condition

    False condition selects "False" string.
  3. Final Answer:

    False -> Option A
  4. Quick Check:

    Zero is false, so "False" is printed [OK]
Quick Trick: Zero is false, non-zero is true in conditions [OK]
Common Mistakes:
  • Treating 0 as true
  • Printing pointer address instead of string
  • Syntax errors in printf

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes