185k views
4 votes
Write the definition of a function minmax that has five parameters. the first three parameters are integers. the last two are set by the function to the largest and smallest of the values of the first three parameters. the function does not return a value. the function can be used as follows: int a=31, b=5, c=19 big, small; minmax(a,b,c,&big,&small);

User Mkebri
by
7.0k points

2 Answers

5 votes

Answer:

void minMax(int a, int b, int c, int*big, int*small)

{

if(a>b && a >c){

*big = a;

if(b>c)

*small = c;

else

*small = b;

}

else if (b>a && b>c){

*big = b;

if(a>c)

*small = c;

else

*small = a;

}

else{

*big = c;

if(a>b)

*small = b;

else

*small = a;

}

}

Explanation:

MPL

User Nouman Bhatti
by
5.5k points
3 votes
Hello,


function minmax(int p1,int p2,int p3, int adr_big, int adr_small)
{ int mini=p1,maxi=p1;
if (p1>p2) {mini=p2;}
else {maxi=p2;};

if (p3>maxi) maxi=p3;
if (p3<mini) mini=p3;
*adr_big=maxi;
*adr_small=mini;
};

// main
int a=31,b=5,c=19,big,small;
minmax(a,b,c,&big,&small);





User Brayn
by
6.6k points