C program to calculate median of an array
Basically a median is the value present at the centre of a sorted array list. To calculate the median first we need to sort the list in ascending or descending order.
If the number of elements are even, then the median will the average of two numbers in the middle.
But the number is odd then the middle element of the array after sorting will be considered as the median.
Given N elements of integer array and we have to find its median in C.
Array elements are:
3, 2, 1, 4, 6
Sorted array is:
1, 2, 3, 4, 6
The median is : 3.000000