Preprocessor Directives in C Programming


Preprocessor directives are the special instructions which are executed before code passes through the compilation process.

Every C programs are checked for the preprocessor statements before compiling and if any preprocessor statements are used in the program then they are processed first and then preprocessed program is handed over to the compiler for further compilation.

Since every preprocessor statements are processed first and this is the reason for calling them preprocessor directives. It begins with hash (#) symbol and do not require semicolon at the end.

One of the most important preprocessor directive is #include which is used for including header file.

For examples:


#include<stdio.h>
#include<conio.h>
#include<math.h>

Similarly, #define is another commonly used preprocessor directive which is used for creating symbolic constants and for defining macros.

For examples:


#define PI 3.141592
#define SIZE 10

Other examples of preprocessor directives are: #if, #else, #endif, #undef etc.