- Asked 2/16
- 2071 Chaitra · 2 marks
- 2068 Chaitra · 2 marks
Preprocessor directives
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.
What are preprocessor directives? Why are they needed?
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.hso 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.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Math Training Institute use case diagram · Object Oriented Analysis and Design, chapter 2
- Choose best words (grammar) 2071 Shrawan · Communication English, chapter 3