Difficulty: Medium
Correct Answer: No
Explanation:
Introduction / Context:
Earlier C dialects (pre-C99) allowed implicit function declarations, which made calling a function before its prototype compile with at most a warning. Modern ISO C removed implicit int and implicit function declarations. This question examines whether a call to f2 before any visible declaration compiles cleanly today.
Given Data / Assumptions:
Concept / Approach:
In modern C, a function must be declared before it is used so that the compiler can check the parameter types and return type. Calling f2 in f1 without a prior visible prototype violates this rule and is diagnosed as an error in strict standard modes. Adding a declaration like int f2(int); before f1 resolves the issue.
Step-by-Step Solution:
Verification / Alternative check:
Compile with -std=c11 -Wall -Werror. Without a prototype, the build fails; adding int f2(int); before f1 succeeds.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming “it works on my old Turbo C” implies it is valid today; relying on implicit int or implicit declarations is non-portable and rejected by modern compilers.
Final Answer:
No.
Discussion & Comments