Variance Method in C

Variance is a statistical measure that tells us how measured data vary from the average value of the set of data.

Program of Variance in C


   #include<stdio.h>
   #include<conio.h>
   void main()
   {
    int s=0,b,s1=0,mean,n,i,a[100];
    clrscr();
    printf("Enter the Frequency :- ");
    scanf("%d",&n);
    printf("Enter %d Values in Array :- ",n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        s=s+a[i];
    }
    mean=s/n;
    for(i=0; i<n; i++)
    {
        b=a[i]-mean;
        s1=s1+b*b;
    }
    s1=s1/n;
    printf("Variance :- %d",s1);
    
    getch();
  }

Output

Post Your Comment