Preprocessor and Macro function in C language Reviewed by Momizat on . Like as the declaration of general variable C allow to define identifies with data value by using '# define'.Which is known as preprocessor. it is compile by th Like as the declaration of general variable C allow to define identifies with data value by using '# define'.Which is known as preprocessor. it is compile by th Rating: 0

Preprocessor and Macro function in C language

Like as the declaration of general variable C allow to define identifies with data value by using ‘# define’.Which is known as preprocessor. it is compile by the compiler before the execution of the main source code of the program.
Example:-

#define x 20;

Que:-Input a radius of a circle and print its a area.

#include <stdio.h>;
#include <conio.h>;
#define p 3.14;
main(){
	clrscr();
	float y,z;
	printf("Enter a radius of circle:");
	scanf("%f",&y);
	z=p*(y*y);
	printf("Area is :%f",z);
	getch();

}

Macro function

The preprocessor will replace call macro function used in the program by there function body before the compilation the main feature of macro function are that there will be know explessive function call during execution since the function body each secuated and execuated at the point of macro power during compilation.The directive ‘#define’ indicates the start of macro function.

Syntax:-#define functionname() statement of function

Ex:- Que-create a macro funcion sum to print sum of two numbers.

#include <stdio.h>;
#include <conio.h>;
#define sum() (4+5);
main(){
	clrscr();
	printf("Sum is-%d",sum());
	getch();
}

Comments (7)

Leave a Comment

© 2014 Powered By