I am trying to write a program that will find the meadian and mode of the values in an array.

This is the code I have so far for Median:

Code:

void median (double array[], int numItems)
{
int i, j;
double hold;
for (i = 0; i <(numItems - 1); i++)
{
for (j = i+1; j < numItems; j++)
{
if (array [j] < array [i])
{
hold = array[i];
array[i] = array[j];
array[j] = hold;
}
}
}
if (numItems % 2 == 0)
{
printf ("\nThe median is %.1lf\n", ((array[numItems/ 2] + array[numItems/2 + 1]) / 2));
}
else
{
printf ("\nThe median is %.1lf\n", array[(numItems/ 2)]);
}
}

And for the Mode I have:

Code:

void mode (double array [], int numItems)
{
int largestcount, i, j;
int count [1500] = {0};
double mode;
for (i = 0; i < numItems; i++)
{
for (j = 0; j < numItems; j++)
{
if (i != j)
{
if (array[i] == array[j])
{
count[i];
}
}
}
}
mode = array[0];
largestcount = count[0];
for (i = 0; i <numItems; i++)
{
if (count[i] > largestcount)
largestcount = count[i];
mode = array[i];
}
printf ("\nThe mode is %i\n", mode);
}

I'm having a little trouble trying to figure this one out to.

Any info on this would be great.