Problem Using Two Functions with Pointers

Posted 19 November 2012 - 01:39 PM

Function a:
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:

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.

Replies To: Problem Using Two Functions with Pointers

Re: Problem Using Two Functions with Pointers

Posted 19 November 2012 - 01:41 PM

Function a:
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:

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.