Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Consider the following function. Complete the function that does the following: (a) Take three arguments, int array, int as the length of the array, and

1.Consider the following function. Complete the function that does the following: (a) Take three arguments, int array, int as the length of the array, and int *max. (b) Find the maximum value and the minimum value in the array. (c) The pointer max points to the maximum value. (d) Return the pointer that points to the minimum value. int * findMinAndMax(int a[ ], int length, int * max) { int maxValue = a[0], minValue = a[0]; int maxIdx = 0, minIdx = 0; for (int idx =1; idx < length; idx++) { if (a[idx] > maxValue) { maxValue = a[idx]; maxIdx = idx; } if (a[idx] < minValue) { minValue = a[idx]; minIdx = idx; } } } 2. Consider the above function. Declare an integer array called myArray of length 5. Initialize myArray to 4, 1, -5, 3, 5, in sequence. Declare two pointers ptrMin and ptrMax, both pointing to integer. Call the above function findMinAndMax so that the pointer ptrMin points the the minimum value

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

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions