
Well before starting, let’s look at the basic defention and how we find mean, median and mode. Both these are 3 variables to find the average value or an approximate value of a list, but yet they have different values as they are based on 3 different concepts
Concepts of mean, median and mode
What is mean ?
Mean is same as average. The mean is found by adding up all of the given data and dividing by the number of elements.
Example: Mean of 1,2,3,4,5 is
(1+2+3+4+5 )/5 = 15/3 = 3
What is Median ?
The median is the middle number in an ordered list (ascending or descending). First you arrange the numbers in orders in ascending order, then you find the middle number and save it as median
Example:
1 2 3 4 5
Median is 3
What is Mode ?
Mode is the element which happens most number of time in the list. If no element happens more than once, all elements are considered as mode.
Algorithm
 Start
 Declare an array a[20], sum =0,i=0,j=0,z=0
 Read number of terms n
 Repeat step 5 & 6 while (i<n)
 sum=sum+a[i]
 next i
 mean=sum/n
 if (n%2=0)
median=(a[n/2] +a[n/21])/2
else
median=a[n/2]  print mean and median
 repeat step 11 & 12 when i=0 to n, j=0 to i
 if a[i]=a[j], then b[i]++
 if b[i]>z, then z=b[i]
 For i=0 to n if b[i]=z, print b[i]
 end
Program
#include <stdio.h>main(){ int i,j,x,k=0,n,a[20],z=0,b[20];float sum=0, t,mean,medn,mod;printf(“\n Enter the no. of elements (Max 20)\n”);scanf(“%d”,&n);printf(“Enter the elements\n”);for(i=0;i{scan (“%d”,&a[i]);}for(i=0;i{sum=sum+a[i];}printf(“Sum: %f”,sum);mean=sum/n;}for(i=0;i{ for (j=i+1;j{ if (a[i]>a[j]){ t=a[i];a[i]=a[j];a[j]=t; }}}if (n%2==0)medn=(a[n/2]+a[(n/2)1])/2;elsemedn=a[n/2];for(i=0;i{ for ( j=0; j<i; j++ ){ if (a[i]==a[j])b[i]++;}}for(i=0;i<n;i++){ if (b[i]>z)z=b[i];}printf(“Mean :%f \n Median : %f \n Mean : “, mean, medn);for I i=0; i<n; i++){ if (b[i]==z)printf(“%d\t”, a[i]);}}
Thank you