---
title: "Preprocessor directives"
subject: "Computer Programming"
chapter: 3
key: "semester_1/computer_programming:preprocessor-directives"
source: https://www.bctengineer.com/q/semester_1/computer_programming/preprocessor-directives
site: BCT Engineering
---

# Preprocessor directives

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

- Asked in: 2071 Chaitra, 2 marks; 2068 Chaitra, 2 marks (asked 2 times)
- Video: [C_146 Introduction to Pre-processor in C| Preprocessor Directive  #include | C Programming Tutorials](https://www.youtube.com/watch?v=pw0uGPmGNl8) — Jenny's Lectures CS IT
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/preprocessor-directives
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-3

## Question

What are preprocessor directives? Why are they needed?

## Short answer

Preprocessor directives (lines starting #) run before compilation. They are needed to include headers (#include), define constants/macros (#define), and enable conditional compilation for portability and debugging.

## Answer

**Preprocessor directives** are lines beginning with `#` that are processed by the preprocessor before the actual compilation starts. They are not C statements and do not end with a semicolon.

Common directives: `#include` (include a file), `#define` (macro or constant), `#undef`, `#ifdef` / `#ifndef` / `#endif` (conditional compilation), `#pragma`.

They are needed to:
- include header files such as `stdio.h` so library functions can be used;
- define symbolic constants and macros (`#define PI 3.14159`), making programs readable and easy to change;
- compile portions of code conditionally for different machines or debugging;
- make programs portable and shorter.

## Check yourself

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

1. Preprocessor directives begin with
   A. $
   B. #
   C. @
   D. %
   Answer: B. Processed before compilation. (Key point: Definition)

2. Directives
   A. must end with semicolon
   B. are C statements
   C. do not end with a semicolon
   D. run at runtime
   Answer: C. They are not C statements. (Key point: Semicolon)

3. #define PI 3.14159 is needed to
   A. include a file
   B. end the program
   C. declare a function
   D. define a symbolic constant for readability
   Answer: D. Easy to change. (Key point: Need)

## Related in other subjects

- [Math Training Institute use case diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amath-training-institute-use-case) — Object Oriented Analysis and Design, chapter 2
- [Choose best words (grammar) 2071 Shrawan](https://www.bctengineer.com/question.md?key=semester_5%2Fcommunication_english%3Achoose-best-words-grammar-set-2071s) — Communication English, chapter 3
