Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

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_2

Step: 3

blur-text-image_step3

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