Bird
0
0

Identify the error in this C code snippet:

medium📝 Debug Q14 of 15
C - Basics and Execution Environment
Identify the error in this C code snippet:
int main() {
    int x = 10
    printf("%d", x);
    return 0;
}
AMissing semicolon after variable declaration
BIncorrect printf format specifier
CVariable x is not declared
DMissing return statement
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax line by line

    The line int x = 10 is missing a semicolon at the end, which is required in C.
  2. Step 2: Verify other parts

    The printf format specifier %d matches the integer variable, variable x is declared, and return statement is present.
  3. Final Answer:

    Missing semicolon after variable declaration -> Option A
  4. Quick Check:

    Semicolon missing after int x = 10 [OK]
Quick Trick: Check for missing semicolons after statements [OK]
Common Mistakes:
  • Ignoring missing semicolon errors
  • Assuming printf format is wrong
  • Thinking return statement is optional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes