Preprocessor is very good feature of c programming language.It will increase the readability of any program.The C preprocessor provides several things that are unavailable in other high-level programming languages.Preprocesors starts with the symbol '#'. We have used it many times in c programming at the time when we include any file at the starting of the program.A set of commonly used preprocesors are shown below:
1.Macro submission Directives
2.File inclusion directives.
The preprocessor directives can be placed anywhere in c program before main() function or and UDF function.
Let us understand bit about macro by the following programs:
1.First program
#include<stdio.h>
#include<conio.h>
#define Pi 3.14
main()
{
float r=5,ans;
clrscr();
ans=Pi*r*r;
printf("Area of circle having radius %f is %f",r,ans);
getch();
}
output:
Area of circle having radius 5.000000 is 78.500000
2.Second program
#include<stdio.h>
#include<conio.h>
#define condition (20<=a<=30)
main()
{
int a=25;
clrscr();
if(condition)
{
printf("True");
}
else
{
printf("Flase");
}
getch();
}
1.Macro submission Directives
2.File inclusion directives.
The preprocessor directives can be placed anywhere in c program before main() function or and UDF function.
Let us understand bit about macro by the following programs:
1.First program
#include<stdio.h>
#include<conio.h>
#define Pi 3.14
main()
{
float r=5,ans;
clrscr();
ans=Pi*r*r;
printf("Area of circle having radius %f is %f",r,ans);
getch();
}
output:
Area of circle having radius 5.000000 is 78.500000
2.Second program
#include<stdio.h>
#include<conio.h>
#define condition (20<=a<=30)
main()
{
int a=25;
clrscr();
if(condition)
{
printf("True");
}
else
{
printf("Flase");
}
getch();
}