In statistics, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. Write a function that accepts as arguments the following:
A) An array of integers
B) An integer that indicates the number of elements in the array
The function should determine the median of the array. This value should be returned as a double.
Demonstrate your pointer prowess by using pointer notation instead of array notation in this function.
The code I have is below. I am not receiving any errors, but I am also not receiving any feedback in regards to my median function. My professor wanted us to incorporate selection sorting and that is the only output I'm receiving. Please help!
int main()
{
constint SIZE =9;
int values [SIZE] ={5,1,3,2,9,4,6,7,8};
// ...
double arrayMedian( int *array[], int num ); // this declares the function
arrayMedian( values, SIZE ) ; // this calls the function (this is what you want to do)
}
You got these right: void selectionSort (int [], int); and void showArray (const int [], int);
The median function is similar: double arrayMedian ( const int array[], int size ) ;
Like in showArray, we do not need to modify any of the numbers in the median function; ergo the const qualifier.
Note: These two are equivalent; in both, the type of the parameter array is 'pointer to const int'
double arrayMedian ( const int array[], int size ) ;
double arrayMedian ( const int* array, int size ) ;