Bird
0
0

Identify the error in the following code snippet:

medium📝 Debug Q14 of 15
C - Input and Output
Identify the error in the following code snippet:
int x;
printf("Enter a number: ");
scanf("%d", x);
printf("You entered %d", x);
AMissing & before variable x in scanf
BWrong format specifier in scanf
CMissing semicolon after printf
DVariable x not declared
Step-by-Step Solution
Solution:
  1. Step 1: Check scanf usage

    scanf("%d", x); is incorrect because it should use &x to pass the address.
  2. Step 2: Confirm other parts are correct

    Format specifier is correct, semicolons are present, and x is declared.
  3. Final Answer:

    Missing & before variable x in scanf -> Option A
  4. Quick Check:

    scanf needs &variable for input [OK]
Quick Trick: Always use & before variables in scanf except arrays [OK]
Common Mistakes:
  • Omitting & causing segmentation fault
  • Using wrong format specifier
  • Assuming scanf prints output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes