---
title: "Need of stdio.h header file"
subject: "Computer Programming"
chapter: 3
key: "semester_1/computer_programming:stdio-header-need"
source: https://www.bctengineer.com/q/semester_1/computer_programming/stdio-header-need
site: BCT Engineering
---

# Need of stdio.h header file

Computer Programming · Chapter 3: Introduction to ‘C’ programming

- Asked in: 2069 Chaitra, 2 marks
- Video: [What is stdio.h? A brief look into libraries in C](https://www.youtube.com/watch?v=hM6dUbgpnmk) — <r.teaches>
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/stdio-header-need
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-3

## Question

Why do we include <stdio.h> in our program? Can we write a C program without using any header file?

## Short answer

<stdio.h> contains function prototypes and macros for standard I/O like printf and scanf. Without it, the compiler may warn or error. A C program can work without any header if it uses no library functions, or if we declare the needed prototype manually.

## Answer

We include `<stdio.h>` (standard input/output header) because it contains the declarations (prototypes) of the standard I/O functions such as `printf()`, `scanf()`, `getchar()`, `putchar()`, `gets()` and the file functions, as well as macros such as `NULL` and `EOF`. Without it the compiler does not know these functions and gives an error or warning.

**Can we write a C program without any header file?** Yes, if the program does not use any library function. For example:
```c
int main(void)
{
    int a = 2, b = 3;
    return a + b;     /* no library function used, so no header needed */
}
```
This compiles and runs; it just returns 5 to the operating system. It is also possible to use `printf` without the header by declaring its prototype ourselves:
```c
int printf(const char *format, ...);   /* declare printf ourselves */
int main(void)
{
    printf("Works without stdio.h\n");
    return 0;
}
```
Output:
```text
Works without stdio.h
```

In practice, headers are included so that functions are declared correctly.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why do we include <stdio.h>?
   A. It contains declarations of I/O functions like printf and scanf
   B. It makes the program faster
   C. It is required to define main
   D. It allocates memory
   Answer: A. It declares the standard I/O functions and macros such as NULL and EOF. (Key point: Why include)

2. Can a C program be written without any header file?
   A. No, never
   B. Yes, if no library function is used
   C. Only with printf
   D. Only in C++
   Answer: B. A program using no library function needs no header. (Key point: Without header)

3. How can printf be used without stdio.h?
   A. It cannot
   B. By declaring its prototype ourselves
   C. By writing #define printf
   D. By using scanf
   Answer: B. Declaring int printf(const char *format, ...); is enough. (Key point: printf without header)

## Related in Computer Programming

- [Correct program: do-while and pow](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acorrect-program-sum-root) — Computer Programming, chapter 3
- [Correct program: Celsius to Fahrenheit](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acorrect-program-celsius-fahrenheit) — Computer Programming, chapter 3
- [Output of arithmetic expression program](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aoutput-expression-xyz) — Computer Programming, chapter 3
- [Correct program: character arrays](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acorrect-program-char-arrays) — Computer Programming, chapter 7
- [Need of analysis and design](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aanalysis-design-before-coding) — Computer Programming, chapter 2
- [Copy contents of one file to another](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-copy-contents) — Computer Programming, chapter 10, asked 2×

## Related in other subjects

- [Why do we need DFT](https://www.bctengineer.com/question.md?key=semester_7%2Fdigital_signal_analysis_and_processing%3Awhy-need-dft) — Digital Signal Analysis and Processing, chapter 7, asked 6×
- [Why do we need FFT](https://www.bctengineer.com/question.md?key=semester_7%2Fdigital_signal_analysis_and_processing%3Awhy-need-fft) — Digital Signal Analysis and Processing, chapter 7, asked 2×
- [File stream; student binary file program](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Afile-stream-student-binary) — Object Oriented Programming, chapter 8
- [File size: 20 s, 44.1 KHz, 8-bit stereo](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aaudio-size-20s-44khz-8bit) — Multimedia System, chapter 2, asked 2×
