1) What is the purpose of Macros? In your opinion, do you believe a Macro function has any weaknesses?
In general, Macros play an imperative role in defining a constant which is repeatedly used in a program. Consider the code snippet:
#define PI 3.14
We have defined value of PI=3.14 and wherever we use PI it will get
replaced with 3.14.
Macros can be used to accept parameters as well. If we need same lines of code to be used repetitively, macros come in handy.
The weakness of macros are:
i) They are very difficult to bug
ii) No type checking occurs
iii) Increases program size for execution
Get Answers For Free
Most questions answered within 1 hours.