Question: int addf(int a, int b) { return a + b; } int cubef(int a) { return a * a * a; } int minf(int a,
int addf(int a, int b) { return a + b; } int cubef(int a) { return a * a * a; } int minf(int a, int b) { if (a
2.1 Write four macros to re-implement the given four functions. Name them: addm, cubem, minm, and evenm, respectively. [10 points] 2.2 Make a C file having the four functions and four macros defined in previous question. Write a main function to test the functions and macros. Use the following test cases in the main function to call your functions and macros in this order: [5 points] int a = 6, b = 8; addf(a, b); addm(a, b); addf(a++, b--); a = 6, b = 8; addm(a++, b--); a = 6, b = 8; cubef(a); cubem(a); cubef(--a); a = 6, b = 8; cubem(--a); a = 6, b = 8; CSE240 Introduction to Programming Language 3 | Page Homework 02
minf(a, b); minm(a, b); minf(--a, --b); a = 6, b = 8; minm(--a, --b); a = 6, b = 8; evenf(a); evenm(a); evenf(a++); a = 6, b = 8; evenm(a++); You must insert print statements to print every function call and macro above, so that the expected output looks like the following:
Your output should have actual answers, not zeros! Take a screenshot of the output. Mark the outputs in color where the function and corresponding macro generated different outputs
kbagewad@general2:-/cse240/hw2$ gcc hw2 kbagewad@general2:/cse240/hw2$ ./q2 addf (a, b) 0 addm (a, b)0 addf (a++, b-0 addm (a++, b-0 cubef (a) 0 cubem (a)0 cubef (--a0 cubem (-a) = 0 inf (a, b)0 ninm (a, b) = 0 mint(--a, --b) = 0 inm (-a,-b) = 0 event(a) = 0 evenm (a)0 evenf (a+t)0 evenm(a++) =0 kbagewad@genera 12. ~/cse240/hw25 q2.c-o q2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
