In C Write a method called GetArrayMedian that takes a sorte
In C# Write a method called GetArrayMedian() that takes a sorted array of doubles as its only parameter (they are sorted from lowest to highest), and returns the median value (a double) of the array. It does not print the median value, it returns it. The median value is the value in the middle of the array if there is an odd number of values, but if there is an even number, then it is the average of the two middle values. You can assume the array that is passed has at least one element in it.
Solution
public static double GetArrayMedian(double[] values)
{
double median=0.0;
if(values.Length%2==0)
median=(values[(values.Length/2)-1]+values[(values.Length/2)])/2;
else median=values[int(values.Length/2)];
return median;
}
