Bird
0
0

Given the code int main() { printf("Hi"); return 0; }, which error occurs if you compile with gcc file.c but forget to include #include <stdio.h>?

medium📝 Debug Q14 of 15
C - Basics and Execution Environment
Given the code int main() { printf("Hi"); return 0; }, which error occurs if you compile with gcc file.c but forget to include #include <stdio.h>?
APreprocessing error
BLinker error
CCompilation warning or error about implicit declaration
DNo error, program runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Identify missing header impact

    Without #include <stdio.h>, the compiler does not know the prototype of printf, causing implicit declaration warning or error.
  2. Step 2: Understand error type

    This is a compilation warning or error, not a linker or preprocessing error.
  3. Final Answer:

    Compilation warning or error about implicit declaration -> Option C
  4. Quick Check:

    Missing stdio.h = compilation warning/error [OK]
Quick Trick: Always include stdio.h for printf to avoid compile errors [OK]
Common Mistakes:
  • Thinking it's a linker error
  • Assuming no error occurs
  • Confusing preprocessing errors with compilation errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes