/* 4 PROGRAM TO CALCULATE WEIGHTED ARITHMETIC MEAN*/
#include<stdio.h>
int main()
{
int x[]={71,83,73,74,65,66};
int w[]={3,4,5,2,3,3};
float wam,wt=0,wtx=0;
int i,wx[6];
printf("\n COMPUTATION OF WEIGHTED MEAN");
for(i=0;i<6;i++)
{
wt=wt+w[i]; /* SUM OF W */
wx[i]=x[i]*w[i]; /* MULTIPLICATION OF X*W */
wtx=wtx+wx[i]; /* SUM OF X*W */
}
printf("\n\n\tX\tW\tX*W\n\n");
for(i=0;i<6;i++)
printf("\n\t%d\t%d\t%d\n",x[i],w[i],wx[i]);
wam=wtx/wt;
printf("\n The sum of W is:-%f",wt);
printf("\n The sum of X*W is:-%f",wtx);
printf("\n The Weighted Arithmetic Mean is:-%f",wam);
return 0;
}
/*OUTPUT:-
COMPUTATION OF WEIGHTED MEAN
X W X*W
71 3 213
83 4 332
73 5 365
74 2 148
65 3 195
66 3 198
The sum of W is:-20.000000
The sum of X*W is:-1451.000000
The Weighted Arithmetic Mean is:-72.550003
*/
No comments:
Post a Comment
This Blog helps you to learn basics to high level programming coding and practicals.
conceptual understanding