Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 <= b) {

return a;

} else {

return b; } }

int evenf(int a) {

if (a % 2 == 0) { return 1; } else { return 0; } }

5.1 Write four macros to re-implement the given four functions. Name them: addm, cubem, minm, and evenm, respectively.

Write the main function to test the functions and macros. Use the following test cases in the main function to call your macros: [5 points]

int a = 5, b = 7;

addf(a, b);

addm(a, b);

addf(a++, b--);

a = 5, b = 7;

addm(a++, b--);

a = 5, b = 7;

cubef(a);

cubem(a);

cubef(--a);

a = 5, b = 7;

cubem(--a);

a = 5, b = 7;

minf(a, b);

minm(a, b);

minf(--a, --b);

a = 5, b = 7;

minm(--a, --b);

a = 5, b = 7;

evenf(a);

evenm(a);

evenf(a++);

a = 5, b = 7;

evenm(a++);

Your main function must print the results of the test run. In the code above, a and b is reinitialized after incrementing or decrementing in function/macro parameter. For questions 5.1 and 5.2, submit your program as a part of p02q5.c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions