Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #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);}

image text in transcribed

emacs24@vm-for-1310 File Edit Options Buffers Tools CHelp #include #include int minmax(int a, int b, int *min, int * max) assert (min != NULL) if (min == NULL 11 max == NULL){ return -1;) if (a>b) return ; else (b>a) return 0; int main (void) int t =minmax (3,5, m=3 NULL, NULL) int x, y int -:-minmax.c minmax (m, &y); (C/l Abbrev) err &x, r, Top L1 = *-mode: compilation; default-directory: "-/hw2Alsulaiman Jehan/pb Compilation started at Thu Feb 1 18:30:25 2 51" -*. -gcc -Wall -Wextra -g -o minmax minmax.d /bin/bash: -g: invalid option Usage: /bin/bash [GNU long option] [option] /bin/bash [GNU long option] [option] script-file GNU long options: - -debug --debugger dump-po-strings -- dump-strings -help --init-file ogifiting To with - -noediting (Compilation:exit [2]) U%*-*compilation* Top L1 Compilation exited abnormally with code 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

From Herds To Insights Harnessing Data Analytics For Sustainable Livestock Farming

Authors: Prof Suresh Neethirajan

1st Edition

B0CFD6K6KK, 979-8857075487

More Books

Students also viewed these Databases questions

Question

Question 21: What is meant by support, confidence and lift?

Answered: 1 week ago