Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
C - Operators and Expressions
Identify the error in this code snippet:
int a = 5;
int b = 10;
int min = a < b ? a, b;
AIncorrect use of comma instead of colon
BMissing semicolon after declaration
CNo error, code is correct
DMissing colon ':' in ternary operator
Step-by-Step Solution
Solution:
  1. Step 1: Check ternary operator syntax

    The ternary operator requires a colon ':' between true and false values.
  2. Step 2: Identify the error in code

    Code uses a comma ',' instead of colon ':' which is incorrect.
  3. Final Answer:

    Incorrect use of comma instead of colon -> Option A
  4. Quick Check:

    Comma is not valid in ternary operator [OK]
Quick Trick: Use ':' not ',' between true and false values [OK]
Common Mistakes:
  • Using comma instead of colon
  • Omitting colon
  • Confusing ternary with comma operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes