Bird
0
0

Find the error in this C code snippet that reads and prints a number:

medium📝 Debug Q14 of 15
C - Input and Output
Find the error in this C code snippet that reads and prints a number:
#include <stdio.h>
int main() {
  int num;
  printf("Enter number: ");
  scanf("%d", num);
  printf("Number is %d\n", num);
  return 0;
}
AMissing & before num in scanf
BWrong format specifier in printf
CMissing semicolon after printf
DNo error
Step-by-Step Solution
Solution:
  1. Step 1: Check scanf argument

    scanf needs the address of variable to store input, so &num is required.
  2. Step 2: Verify other parts

    printf uses correct format %d and semicolons are present.
  3. Final Answer:

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

    Use & with scanf variable [OK]
Quick Trick: Always use & before variable in scanf [OK]
Common Mistakes:
  • Forgetting & in scanf argument
  • Changing printf format specifier wrongly
  • Missing semicolons

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes