Preprocessor Directives

Preprocessor Directives

In this tutorial we are going to learn Preprocessor directives in c.

Preprocessor directives are the statements which tells the compiler to change the program floor to include library in file (or to import external files).

Preprocessor directives are the first statement of the program.

Preprocessor directives are start with the # symbol and it does not contain semicolon at the end.

There are some preprocessor directives in c which are as follows






Include directives :-

  • Include directives is inclusion directives
  • Include directives is used to include or import the file to program.

Syntax :-




In above syntax, we first write # symbol , include keyword and file name in between < and > operator or in between double quotes.

Example :-


In above example, this statement tells compiler to include stdio.h library file to the program.

Program to illustrate include preprocessor directives in c 

1234567891011121314151617#include<stdio.h> // include preprocessor directives#include<conio.h> //void main (){clrscr ();. //Included in conio.h fileprintf(“\n Preprocessor directives in c”);printf(“\n standard input output file included:”);getch();}


Preprocessor directives in c

Standard input output file included

#define or macro directives :-

This directives is called as definition directives.

These directives used to define symbolic constant or macros.

Macro is a expression or statement which are expanded in program when to called.

Syntax :-

#define NAME VALUE


# define #EXP(A) expansion_in_A

In above syntax, every occurrences of NAME and EXP(A) is replaced by appropriate statement or expression in preprocessor.

Program to illustrate #define preprocesor directives in c

12345678910111213141516171819#include<stdio.h>#define F(X) X*Xvoid main(){int x,y;printf(“Enter The Value Of ‘X’ : “);scanf(“%d”,&x);y=F(X);printf(“\nSolution : %d”,y);}


Enter The Value Of ‘X’ :


Solution : 16