C pre processor



These are the part of the program that is processed before the actual compilation of the program , by processing means substitution of some text by another

Let us take an example to make this more clear

Suppose in our program we are using the value pi a lot of time , so instead of writing the value again and again we can write this before the main part

#define PI 3.14;


So now we can replace the value with the word pi in our program like

PI * 20;

Or something like this

This is one of the pre processor directive , we also have #include followed by the file name

The c pre processor makes the program more user friendly and readable  

The following example will make it more clear


#include<stdio.h> // #include pre processor

#define PI 3.14 // #define preprocessor

main()
{
     
      float radius = 4;
     
      float area;
     
      area = PI * (radius * radius);
     
      printf(" area is %f \n",area);
     
      getch();
     
      }

No comments:

Post a Comment