Difficulty: Easy
Correct Answer: #include
Explanation:
Introduction:
The function log is part of the C math library. This question checks whether you can identify the correct header needed to declare and use log properly.
Given Data / Assumptions:
Concept / Approach:
In C, mathematical functions such as log, exp, sin, and cos are declared in math.h. Including the proper header ensures correct declarations and types. Some toolchains also require linking with the math library (e.g., -lm) at link time.
Step-by-Step Solution:
1) Identify log as a natural logarithm function.2) Recall its declaration resides in math.h.3) Add the line #include
Verification / Alternative check:
Compile with and without the header to see that the version without math.h yields warnings or errors about implicit declaration or mismatched types.
Why Other Options Are Wrong:
conio.h: Non-standard header for console I/O on some DOS compilers; unrelated to log.stdlib.h: General utilities (malloc, exit, atoi, etc.), not log.dos.h: Platform-specific DOS functions; not math.
Common Pitfalls:
Forgetting to link the math library on Unix-like systems. Also, using %f in printf with log is fine because log returns double.
Final Answer:
#include
Discussion & Comments