Preprocessor directives in C are the statements which tell the compiler to change the program floor to include the library in a file (or to import external files).
Preprocessor directives are the first statement of the program.
Preprocessor directives 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
#error
#define
#if
#if else
Etc

Include directives

Include directives are inclusion directives
Include directives in c is used to include or import the file to program. It is used to include the external files or directive into our program.
Include directive must be the first line of the code. You must include the directive or file before using this method or functions in the program.

Syntax to include directives: –
#include<file_name>
Or
#include”file_name”
In above syntax, we first write # symbol, include keyword and file name in between < and > operator or in between double quotes.

Example: –
#include<stdio.h>
In above example, this statement tells compiler to include stdio.h library file to the program.

Program to illustrate include preprocessor directives in c

#include<stdio.h> // include preprocessor directives

#include<conio.h> // include preprocessor directives

void main ()

{

clrscr ();. //Included in conio.h file

printf("\n Preprocessor directives in c");

printf("\n standard input output file included:");

getch();

}

Output:-

Preprocessor directives in c #define or macro directives: –

This directive is called as definition directives.
These directives used to define symbolic constant or macros.
Macro is an expression or statements which are expanded in the program when it is called in the program.

The syntax for define macro: –
#define NAME VALUE
Or
# define
#EXP(A) => expansion in A
In the above syntax, every occurrence of NAME and EXP(A) is replaced by an appropriate statement or expression in the preprocessor.

Program to illustrate #define preprocessor directives in c

#include <stdio.h>
#define F(X) X*X
int main()
{
int x,y;

printf("Enter The Value Of ‘X’ : ");

scanf("%d",&x);

y=F(x);

printf("\nSolution : %d",y);

return 0;
}

Output:-

Preprocessor directives in c

Write A Comment