Numerical Program

Median Method Definition

The "mean" is the "average" you're used to, where you add up all the numbers and then divide by the number of numbers. The "median" is the "middle" value in the list of numbers.

Program of Median in C Language

  #include<stdio.h>
  #include<conio.h>
  void main()
  {
    int a[100],n,i,median;
    clrscr();
    printf("Enter the Frequency :-");
    scanf("%d",&n);
    printf("Enter %d Values of n :- ",n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    if(n%2==0)
    {
        median=(a[(n+1)/2]+a[n/2])/2;
    }
    else
    {
        median=a[(n+1)/2];
    }
    printf("Median :- %d",median);
    
    getch();
  }
    

Output

Enter the Frequency :- 5

Enter 5 Values of n :- 2

3

4

5

6

Median :- 5

Post Your Comment

Some Useful Tricks of Windows

Follow us on Facebook

Advertisement