Question: 2. Macros are available in most high-level programming languages. The body of a macro is simply used to replace a macro-call during the preprocessing stage.

 2. Macros are available in most high-level programming languages. The body

of a macro is simply used to replace a macro-call during the

2. Macros are available in most high-level programming languages. 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 is to demonstrate the differences: between a function and a macro. Observe each of the functions below, written in Cr and understand their functionality. You can use either GNU gcc under Unix or Visual Studio to implement the code in this question. 2.1. Write, in C, four macros to re-implement the given four functions. Name them: subm, squared_addm, smal1erm, and evenm, respectively. [40 points] 2.2. Make a C file a02p02.c having the four functions and four macros defined in previous question. Write a main() function to test these functions and macros. Use the following test cases in the main() to call your functions and macros in this order and observe the results: [10 points] You must insert print statements to print the test case running and the answer of every function call and macro call above, so that the expected output looks like the following for each test case: test case 1 subf {a,b=0, while a=0,b=8 subm(a,b)=, while a=,b= subm (a++,b)=, while a=8,b= Your output should have actual answers, not zeros! Take a screenshot of the output with all the test cases in the same program. Mark the lines in color where the functionmacro pair gives different results, like the example for subf (a+4,b) and subm(a+4, b) in the figure above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!