How to write a function that receives a double array along with its length. if the number of elements of the array is odd the function returns the number that is in the middle of the array. if the number of elements in the array is even, then the function returns the average of the two numbers that are in the middle of the array.
I am in a good mood so will give a framework of how this can be done. Though just a tip next time be a bit more specific on exactly what you having trouble with.
double arrayFunction(double theArray[], unsigned arraySize)
{
// We will use this variable to either hold the middle elements value
// or the average of the two middle elements values.
double result;
// Here the if condition should test if the size is odd
if (...)
{
// If the size is odd we need to find the middle element.
// After we found it assign that elements value to result.
}
// The else portion will handle if the array size is even
else
{
// Here we need to find out the average of the two middle numbers.
// After we found it assign that value to result.
}
return result;
}
If there is anything you don't understand just let us know.