Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Convert the following functions to macro in C only! please only respond if you know it, don't spam. The body of a macro is simply
Convert the following functions to macro in C only! please only respond if you know it, don't spam.
The body of a macro is simply used to replace a macro-call during the preprocessing stage. A macro introduces a "true inline" function that is normally more efficient than an "out-line" function. However, macros suffer from the side-effect, unwanted, or unexpected modifications to variables. Macros should be used cautiously. The main purpose of the following programs are to demonstrate the differences between a function and a macro. Other purposes include demonstrating the differences between different programming environments, and learning different ways of writing comments, formatted input and output, variable declaration and initialization, unary operation ++, macro definition/call, function definition/call, if-then-else and loop structures, etc. Observe each of the functions below and understand their functionality. Next, convert each of the following functions to macros. Create a C file and test the macros that you have defined by writing a main function to call the functions and macros. Each macro is worth 3 points, including a main function which tests each macro is worth the remaining 3 points. Submit your program labeled as hw02q2.c int square(int a) { return a * a: } int add(int a, int, b) { return a + b: } int min(int a, int b) { if (aStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started