Search
 
SCRIPT & CODE EXAMPLE
 

C

calculate 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 :: malloc c 
C :: c print 2d array 
C :: Program to Check Whether Character is Lowercase or Not without using islower function 
C :: How to copy one string into another in C 
C :: faire une facture en langage c 
C :: eliminare file in c 
C :: empiler une pile on c 
C :: chevront de vlavier 
C :: square in c 
C :: access 2d array with pointer c 
C :: stddef.h 
C :: stack and heap memorym in ram 
C :: function that changes all lowercase letters of a string to uppercase. 
C :: C# special character display 
C :: static variable c 
C :: les fichiers en c 
C :: what is O(N^2) in bubble sort method 
C :: 2 html 1 javascript 
C :: entity framework core discard changes 
C :: run a command in cmd with c 
C :: block quote in lua 
C :: c create array 
C :: code_art_bcm_10.c 
C :: georgia institute of technology 
C :: turn on and turn off different device at the same time in rainmaker 
C :: Convert arduino String to C language String 
C :: analog clock c code for turbo 
C :: return multiple values using the call by reference 
C :: how to turn off bash 
C :: navigate to line intellij 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =