MACRO
MACRO
Macro is a
Pre-processor directive which is used to declare symbolic constants.
Example: # define
UPPER 25
The above
statement is called ‘Micro Defination’(Macro), ‘UPPER’ is called ‘ MACRO
TEMPLATE’
And 25 is
called corresponding ‘macro expansion’.
It is customary
to use capital letters for micro template.
Macro definition never to be terminated by a semicolon.
Macro can have
arguments.
Example:
# define AREA(x) (3.14 *X *X)
Main()
{
Float r1=6.25,a;
a=AREA(r1);
printf(“Area is
=%f”,a);
}
MACROS
Vs Function
In a micro call
preprocessor replaces the micro template
with it’s micro expansion.
In a function call, the control is passed to function along with certain arguments, after performing the talks in that fun a useful value is returned
back.
Macros make the
program run faster but increase the program size.
Function make the program smaller and compact
but takes time to passing the control between functions.
File Inclusion
This directive causes one file to be included in another file. There are
two ways to write
# include<filename.h>
# include “filename.h”
1. Macro
Expansion.
Comments
Post a Comment