Search
 
SCRIPT & CODE EXAMPLE
 

C

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 :: variable swap in c 
C :: pop and push shows black screen which needs to be pressed back flutter 
C :: recursive in c 
C :: pid of a process in c 
C :: apt-mark remove hold 
C :: pendu langage c 
C :: Initialization of a 3d array in c 
C :: subrayar elementos css 
C :: sizeof file c 
C :: boolean input in c 
C :: yum install supervisor amazon linux 
C :: command args c 
C :: array of strings c 
C :: script in c 
C :: check command line input is a number in c 
C :: increment pointer value in c 
C :: bp result system 
C :: C/AL Convertion of Decimal to String/Text 
C :: do a barrel roll 
C :: string text line 
C :: anthracnose pronounce 
C :: how to get out of function in c 
C :: binary operations on structs C 
C :: java Node<E 
C :: how many archaeologists are there 
C :: C (K&R) 
C :: WAP to create Database using array of structure & display it in C 
C :: how to devowel string in c program 
C :: C programming statician 
C :: passing an array of unspecified number of variables to a function 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =