I'm using Visual Studio and trying to write a small program that takes an array, sorts it in ascending order and then calculates average, mode and median of those values.
So far i have sorted it using selective sort, calculated the average but am struggling with the mode and median.
This is what i have for my median function so far. I beleive the theory should work behind it.
Code:
double getMedian(int num[], int length )
{
double value;
int position = 0;
value = 0;
if (length % 2 != 0)
{
position = (length / 2);
value = num[position];
}
else
{
position = (length / 2);
value = (num[position]+num[position-1])/2;
}
return value;
}


