#include<stdio.h>
#include<math.h>
int main()
{
int x[]={1,2,3,4,5,6};
int f[]={5,9,12,17,14,10};
int i;
float lx[6],lf[6],gm=0,sl=0,n=0;
printf("\n COMPUTATION OF GEOMETRIC MEAN");
for(i=0;i<6;i++)
{
lx[i]=log(x[i]); /* Calculation of Log(X) */
lf[i]=lx[i]*f[i];/* Multiplication of Log(X)*Frequency */
n=n+f[i]; /* Addition of Frequency */
sl=sl+lf[i]; /* Addition of Log(X)*Frequency */
}
printf("\n\n\tX\tF\tLog(X)\t\tLog(X)*F\n\n");
for(i=0;i<6;i++)
printf("\n\t%d\t%d\t%f\t%f\n",x[i],f[i],lx[i],lf[i]);
gm=exp(sl/n);
printf("\n\n The Total Frequency Is:-%f",n);
printf("\n\n Sum of LOGX[i]*F[i] Is:-%f",sl);
printf("\n\nThe Geometric Mean Is:-%f",gm);
return 0;
}
/* OUTPUT:-
COMPUTATION OF GEOMETRIC MEAN
X F Log(X) Log(X)*F
1 5 0.000000 0.000000
2 9 0.693147 6.238325
3 12 1.098612 13.183348
4 17 1.386294 23.567005
5 14 1.609438 22.532131
6 10 1.791759 17.917595
The Total Frequency Is:-67.000000
Sum of LOGX[i]*F[i] Is:-83.438408
The Geometric Mean Is:-3.474148 */
No comments:
Post a Comment
This Blog helps you to learn basics to high level programming coding and practicals.
conceptual understanding