Finding the Median

closed account (98qiz8AR)
I am trying to find the median of an array in c++. Can anyone help?

This is the array that I would like to find the median for.

scores[14] = {62,70,98,71,81,99,74,80,73,88,73,72,95,71};

closed account (98qiz8AR)
I sorted the array already using a function.
 ``12345678910111213141516171819202122232425`` `````` int Median(int nums[], int size) { //Use bubble sort to sort the array. int swapHolder = -1; //integer holder, "temp variable" int end = 14; int length = 14; for(int counter = length - 1; counter > 0; counter--) { for(int index = 0; index < end; index++) { if (nums[index] > nums[index +1]) { swapHolder = nums[index + 1]; nums[index + 1] = nums[index]; nums[index] = swapHolder; } } end--; } } ``````

I am trying to find the mean now. What should I do next after the array is sorted?
Mean or median?
closed account (98qiz8AR)
Median

Should I post my entire code?
 the median is the numerical value separating the higher half of a data sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one (e.g., the median of {3, 5, 9} is 5). If there is an even number of observations, then there is no single middle value; the median is then usually defined to be the mean of the two middle values - Wiki

Pick the middle value (N is odd) or the average of the two middle values (even).
Topic archived. No new replies allowed.