Macro
processor that is used automatically by the C
compiler to transform your program before actual compilation. It is called
a macro processor because it allows you to define macros, which are brief
abbreviations for longer
constructs.
A macro is a segment of code which is replaced by the value of macro. Macro is defined by #define directive.
Macros in C are string replacements commonly used to define constants.
The function-like macro looks like function call. For example:
For example:-
1. #define MAX 1000
It sets the value of identifier MAX to 1000 and whenever you want to use 1000 in your program you can use MAX instead of writing 1000.
2. Argumented macro substitution (this permits us to define more complex and more useful forms of replacements):-
It takes the form:-
#define identifier (f1, f2,.., fn) string
For example, #define CUBE(x) (x*x*x)
If the following statement appear in the prog.-
Volume = CUBE (side);
Then the pre-processor will expand this statement to:
Volume = (side*side*side);
To learn more about C Programming Language
Call us @ 9825618292
Visit us @ www.tccicomputervoaching.com
A macro is a segment of code which is replaced by the value of macro. Macro is defined by #define directive.
Macros in C are string replacements commonly used to define constants.
The function-like macro looks like function call. For example:
For example:-
1. #define MAX 1000
It sets the value of identifier MAX to 1000 and whenever you want to use 1000 in your program you can use MAX instead of writing 1000.
2. Argumented macro substitution (this permits us to define more complex and more useful forms of replacements):-
It takes the form:-
#define identifier (f1, f2,.., fn) string
For example, #define CUBE(x) (x*x*x)
If the following statement appear in the prog.-
Volume = CUBE (side);
Then the pre-processor will expand this statement to:
Volume = (side*side*side);
To learn more about C Programming Language
Call us @ 9825618292
Visit us @ www.tccicomputervoaching.com
No comments:
Post a Comment