Bird
0
0

Find the error in this code:

medium📝 Debug Q7 of 15
C - Operators and Expressions
Find the error in this code:
int x = 10;
int y = (x > 5) ? 20;
AMissing semicolon after assignment
BMissing false value after colon ':'
CIncorrect parentheses usage
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check ternary operator structure

    Ternary operator must have both true and false values separated by colon.
  2. Step 2: Identify missing part

    Code has no false value and no colon, so it's incomplete.
  3. Final Answer:

    Missing false value after colon ':' -> Option B
  4. Quick Check:

    Ternary needs both true and false parts [OK]
Quick Trick: Always include both true and false parts with ':' [OK]
Common Mistakes:
  • Omitting false value
  • Forgetting colon
  • Assuming semicolon ends ternary

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes