Header Ads Widget

What is file inclusion in C / preprocessor directives / Micros in c

 Preprocessor  Directives :-   Preprocessor directives are commands to the compiler  to perform certain task  before the process of  compilation start . These  command are start form symbol ( # ) following  are main preprocessor directives .

File inclusion : -  The preprocessor  directives is used to include the  contains of predefine system header files or user header files .

Example :-        


#include<stdio.h> // To include built in header files.
#include "my header .h" // to include user define header files.

Defining macros : -  Macros are basically symbolic names corresponding to some content or expression 

function before the compilation start the value corresponding to this macros is substituted in the program .

Example 1 :-

# define PI 3.14
int main()
{
float r , a ;
scanf(" %f " , &r);
a = PI*r*r;
printf("Area = %f " , a);
return 0;
}
output:-
Area = 12.560000

Exampple 2:-

#define square(x) ((x)*(x))
int main()
{
int z = 5 , y;
y = square(z);
printf("square of %d is %d",z, y);
return 0;
}
Output:-
square of 5 is 25



Recommended Post:

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-




Post a Comment

0 Comments