Which of the following functions is not declared in <stdio.h>?
2023
Which of the following functions is not declared in <stdio.h>?
- A.
printf()
- B.
scanf()
- C.
fopen()
- D.
sqrt()
- E.
fprintf()
Attempted by 145 students.
Show answer & explanation
Correct answer: D
Concept
The C standard library groups its functions into headers by purpose. The <stdio.h> header declares the standard input/output routines — functions for formatted I/O, file-stream handling, and character/string streams. Mathematical routines such as square root, power and trigonometric functions are NOT I/O; they live in a separate header, <math.h>. To find the odd one out, classify each function by the header that declares it.
Application
Mapping each offered function to its declaring header:
Function | Declaring header | Role |
|---|---|---|
|
| formatted output to stdout |
|
| formatted input from stdin |
|
| open a file stream |
|
| formatted output to a stream |
|
| compute square root (math, not I/O) |
Cross-check / Result
Four of the five — printf(), scanf(), fopen() and fprintf() — are I/O routines declared in <stdio.h>. Only sqrt() is a mathematical function; it is declared in <math.h> and requires linking the math library. Hence the function not declared in <stdio.h> is sqrt().