Computer Science, asked by shubhsinghal8243, 1 year ago

What are macros what are its advantages and disadvantages?

Answers

Answered by garywalter1221
11

Ans.

A macro is a name given to a block of C statements as a pre-processor directive. Being a pre-processor, the block of code is communicated to the compiler before entering into the actual coding (main () function). A macro is defined with the preprocessor directive, #define.

Advantages

Ans.The advantage of using macro is the execution speed of the program fragment. When the actual code snippet is to be used, it can be substituted by the name of the macro. The same block of statements, on the other hand, need to be repeatedly hard coded as and when required.

Disadvantage

Ans.he disadvantage of the macro is the size of the program. The reason is, the pre-processor will replace all the macros in the program by its real definition prior to the compilation process of the program.

Similar questions