Search
 
SCRIPT & CODE EXAMPLE
 

C

function array median

//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;

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

    return median;
}
Comment

PREVIOUS NEXT
Code Example
C :: Leap year using function in c 
C :: create node in c 
C :: transfer function exponent matlab 
C :: hourglass sum 
C :: FCFS algorithm in c to find average turnaround time and waiting time 
C :: imprimir matriz 
C :: iterate through enum in qt 
C :: leggere stringhe con spazio in mezzo c 
C :: why do you jerk while falling aslee 
C :: definir função em c 
C :: Program to print all palindromes in a given range 
C :: vifm preview images 
C :: get boolean from localstorage 
C :: armstrong in c 
C :: windows make clean 
C :: c arrays and pointers 
C :: what is clrsce in C 
C :: c for result 
C :: cast from float to long c 
C :: how tier lists work 
C :: remove language from jupyter notebook 
C :: c program to pass a single element in an funtional array 
C :: Greatest common divisor iterative 
C :: command line arguments to copy paste in c 
C :: Uri/beecrowd problem no - 1099 solution in C 
C :: 50 north main 07522 
C :: C Nested if...else 
C :: Print fabionci with fork in C 
C :: How to get the number of characters in a string without using strlen function 
C :: c addition 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =