Tux Education Our New Education Channel Please Share And Subscribe It...

/* Program To Find Variation, Mean, Standard Deviation */


// Compiler : Dev-C++ 4.9.9.2

#include<stdio.h>
#include<math.h>
#define max 10

int main()
{
    int i,n;
    float x[max], avrg, var, SD, sum=0, sum1=0;
    
    printf("Enter The Value Of N : ");
    scanf("%d",&n);
    printf("\n\nEnter %d Real Numbers.\n\n",n);
    
    for(i=0; i<n; i++)
    scanf("%f",&x[i]);
    
    // Computing The Sum Of All Elements.
    for(i=0; i<n; i++)
    sum+=x[i];
    
    avrg=sum/(float)n;
    
    // Computing Varaience And Standard Deviation.
    for(i=0; i<n; i++)
    sum1+=pow((x[i] - avrg),2);
    
    var=sum1/(float)n;
    SD=sqrt(var);
    
    printf("\n\nAverage            : %.2f",avrg);
    printf("\n\nVarience           : %.2f",var);
    printf("\n\nStandard Deviation : %.2f",SD);
    
    
    getch();
    return 0;
}

Post a Comment