Question
C programming Question 2.5 Exercise 2.5. Write a function that computes the minimum and the maximum imum of two integer variables and returns them through
C programming Question 2.5
Exercise 2.5. Write a function that computes the minimum and the maximum imum of two integer variables and returns them through call-by-reference parameters. It should have the following prototype:
lint minmax(int a, int b, int * min, int * max);
Write a unit test of minmax in a main function.
Aaron R. Bradley. Programming for Engineers: A Foundational Approach to Learning C and Matlab (Kindle Location 415). Kindle Edition.
The code I wrote
#include
int minmax(int a, int b, int *min, int * max){ assert(min != NULL); if(min == NULL || max == NULL){ return -1;} if (a>b) return 0 ; else (b>a) return 0; } int main(void){ int t =minmax(3,5, NULL, NULL) m =3; r =5; int x, y int err = minmax(m, r, &x, &y); assert(err == 0 && x==3 && y==5); err = minmax(r, m, &x, &y);}
emacs24@vm-for-1310 File Edit Options Buffers Tools CHelp #include
Step 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