Header Files & Preprocessor Directives in C

1. What are Header Files?

Header files in C contain declarations of functions and macros. They allow you to reuse code and organize functions logically. They typically have a .h extension and are included using the #include directive.

2. Types of Header Files

3. What are Preprocessor Directives?

Preprocessor directives are commands that begin with # and are processed before the compilation starts. They are used to include files, define macros, and conditionally compile code.

4. Common Preprocessor Directives

5. Example Code

#include <stdio.h>
#define PI 3.14159

int main() {
    printf("Value of PI: %.2f\n", PI);
    return 0;
}

Explanation:
#include <stdio.h> tells the compiler to include standard input-output functions.
#define PI 3.14159 defines a macro constant named PI.

6. Why Use Header Files and Preprocessor Directives?

7. References