A macro in computer science is a rule or pattern that specifies how a certain input sequence should be mapped to a replacement output sequence according to a defined procedure.The mapping process that transform a macro use to a specific sequence is known as macro expansion.
A macro is a segment of code which is replaced by the value of macro.
Note:- A macro is defined by #define directive.
Types of macro
A macro is a segment of code which is replaced by the value of macro.
Note:- A macro is defined by #define directive.
Types of macro
- object like macro:- The object like macro is an identifier that is replaced by value.it is widely used to represent the numeric constant. For Example:- #define pi 3.14; //it means in the program when there is a pi , it is replaced by the 3.14 value.
- function like macro :- this macro look like function call.. For Example:- #define min(a,b) ((a<b)?(a):(b)) //here a function is defined min having two arguments a and b.if a is small then b then a value is defined else b value is defined.The function is used is using a ternary operator.
There are some macro which is already defined(means predefined)
Comments
Post a Comment