Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q14 of 15
C - Input and Output
Find the error in this code snippet:
int a, b;
scanf("%d %d", a, b);
printf("%d %d", a, b);
AMissing semicolon after scanf.
BWrong format specifier in scanf.
Cprintf format specifiers do not match variables.
DMissing & before variables in scanf.
Step-by-Step Solution
Solution:
  1. Step 1: Check scanf arguments

    scanf requires addresses of variables, so &a and &b are needed.
  2. Step 2: Identify error

    Code passes variables a and b directly, causing undefined behavior or crash.
  3. Final Answer:

    Missing & before variables in scanf. -> Option D
  4. Quick Check:

    scanf needs & before variables [OK]
Quick Trick: Always use & before variables in scanf [OK]
Common Mistakes:
  • Forgetting & in scanf
  • Assuming variables auto-pass by address
  • Confusing scanf and printf syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes