0% found this document useful (0 votes)
38 views2 pages

G H College Haveri: Department of Bca

Uploaded by

PRINCIPAL HAVERI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

G H College Haveri: Department of Bca

Uploaded by

PRINCIPAL HAVERI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

KLE SOCIETY’S

G H COLLEGE HAVERI
DEPARTMENT OF BCA

/*WRITE A PROGRAM TO CALCULATE THE COEFFICIENT OF VARIATION (C.V)


FOR TABULATED DATA*/
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
void main()
{
int i,n;
float x[20],f[20],fx[20],x2[20],fx2[20];
float sumx=0,sumf=0,sumfx=0,sumfx2=0,am,d,sd,cv;
clrscr();
printf("Enter the number of observations \n");
scanf("%d",&n);
printf("Enter the observations \n");
for(i=0;i<n;i++)
{
scanf("%f",&x[i]);
}
printf("Enter the frequencies \n");
for(i=0;i<n;i++)
{
scanf("%f",&f[i]);
}
printf("========================================\n");
printf("x[i]\t f[i]\t fx[i]\t x2[i]\t fx2[i]\n");
printf("========================================\n");
for(i=0;i<n;i++)
{
fx[i]=f[i]*x[i];
x2[i]=x[i]*x[i];
fx2[i]=f[i]*x2[i];
printf("%.2f\t %.2f\t %.2f\t %.2f\t %.2f\n",x[i],f[i],fx[i],x2[i],fx2[i]);
printf("=======================================\n");
sleep(1);
}
for(i=0;i<n;i++)
{
sumx=sumx+x[i];
sumf=sumf+f[i];
sumfx=sumfx+fx[i];
sumfx2=sumfx2+fx2[i];
}
printf("%.2f\t %.2f\t %.2f\t %.2f\n",sumx,sumf,sumfx,sumfx2);
KLE SOCIETY’S

G H COLLEGE HAVERI
DEPARTMENT OF BCA
am=sumx/n;
d=sumfx2/sumf;
sd=(sqrt(d-(am*am)));
cv=(sd/am)*100;
printf("=========================================\n");
printf("Airthmetic Mean=%f \n",am);
printf("Standard deviation= %f \n",sd);
printf("Co-efficient of variation= %f\n",cv);
getch();
}
/*=======OUTPUT=========
Enter the number of observations
5
Enter the observations
1
2
3
4
5
Enter the frequencies
3
5
9
6
2
========================================
x[i] f[i] fx[i] x2[i] fx2[i]
========================================
1.00 3.00 3.00 1.00 3.00
=======================================
2.00 5.00 10.00 4.00 20.00
=======================================
3.00 9.00 27.00 9.00 81.00
=======================================
4.00 6.00 24.00 16.00 96.00
=======================================
5.00 2.00 10.00 25.00 50.00
=======================================
15.00 25.00 74.00 250.00
=========================================
Airthmetic Mean=3.000000
Standard deviation= 1.000000
Co-efficient of variation= 33.333332 */

You might also like