This function must accept 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. (Assume the values in the array are already sorted.)
Demonstrate your pointer prowess by using pointer notation instead of array notation in this function.
Question: I am unsure if I am using the array and pointer notation correctly, any help here is appreciated. Note - It is assumed the array is already sorted in ascending order.
My code for Function a:
double* median (int array[ ], int size)
int size, *median;
if(size % 2 = 0)
((array[size]/2) - 1) + ((array[size])/2) / 2 = median;
if(size % 2 = 1)
(array[size]) / 2 = median;
Function b: Write a function that accepts an int array and the array's size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a
pointer to the new array.
Question: I cannot figure out how to initialize the unused elements of the second array with 0. Also, I am unsure of my syntax here using arrays. Finally, how can pointers be implemented into this function? Thanks again.
int expander (int arr[ ], int arraySize)
int arr[ ], arraySize, newArray[ ], newArraySize;
newArraySize = arraySize * 2;
for (i = 0; i <= arraySize - 1; i++)
arr[ i ] = newArray[ i ];