CSEon Basis of Code
CSEon Basis of Code
*program 13.2
The Preprocessor
• A unique feature of C is the preprocessor.
• It is a program that processes the source code before it passes through the compiler
(preprocesses).
• It operates under the preprocessor directives.
• Preprocessor directives are placed in the program before main.
• At first, the preprocessor program checks the source code if there is any preprocessor
directives. If found, appropriate actions are taken accordingly and passes the source code
to the compiler.
• Preprocessor directives start with the symbol # and require no semicolon (;) at the end.
For example, #include and #define (Table 14.1).
• The tools of the preprocessors helps to make a program easy to read and modify, portable,
and more efficient.
The Preprocessor(contd.)
• The Preprocessor directives are divided into three categories:
Macro substitution directives
File inclusion directives
Compiler control directives
Example program:
#define MAX(a,b) ((a>b)?a:b)
main(){
int result,x,y;
scanf("%d%d",&x,&y);
result=MAX(x,y);
printf("Maximum number is %d ",result);
}