c median of an array


c median of an array
//function that receives an array and it's number of elements as ints
//and outputs the array's median value as a float
float CalcMedian(int ar[], int arraySize)
    float median;

    	 //2.0 needs the decimal value so it doesn't truncate the result
        median = (ar[(arraySize-1) / 2] + ar[arraySize/2]) / 2.0;
        median = ar[arraySize/2];

    return median;


Please follow and like us:
Content Protection by DMCA.com