Question: // C programming, PLEASE COMPILE a code to match with the EXPECTED VALUE // MY OUTPUT IS WRONG void minmax(int a[], int len, int *minpos,

// C programming, PLEASE COMPILE a code to match with the EXPECTED VALUE

// MY OUTPUT IS WRONG

void minmax(int a[], int len, int *minpos, int *maxpos) { *minpos=*maxpos=a[0];

for(int i=1; i a[i]) *minpos=a[i]; else if(*maxpos

#include

void minmax(int a[], int len, int* min, int* max);

int main() { int a[] = { 1, 4, -1, -1, 9, 9, -2, 14, -10 }; int min = 42; int max = 1729; minmax(a, 0, &min, &max); printf("min max: %d %d ", min, max); printf("Expected: 42 1729 "); minmax(a, 6, &min, &max); printf("min max: %d %d ", min, max); printf("Expected: 2 4 "); minmax(a, 9, &min, &max); printf("min max: %d %d ", min, max); printf("Expected: 8 7 "); int b[] = { -1, -4, -9 }; minmax(b, 3, &min, &max); printf("min max: %d %d ", min, max); printf("Expected: 2 0 "); return 0; }

/*

OUTPUT

min max: 1 1 Expected: 42 1729 min max: -1 -1 Expected: 2 4 min max: -10 -1 Expected: 8 7 min max: -9 -1 Expected: 2 0

*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!