Here is a C++ program to calculate weighted arithmetic mean
SOURCE CODE OUTPUT
#include <iostream>
using namespace std;
int main()
{
int subject[5][2],totalmean=0,totalweight=0,wam;
cout<<"Enter values and their weight";
for(int i=0;i<5;i++)
cin>>subject[i][0]>>subject[i][1];
for(int i=0;i<5;i++)
totalmean+=subject[i][0]*subject[i][1];
for(int i=0;i<5;i++)
totalweight+=subject[i][1];
wam=totalmean/totalweight;
cout<<"Weighted Arithmetic mean "<<wam;
return 0;
}
using namespace std;
int main()
{
int subject[5][2],totalmean=0,totalweight=0,wam;
cout<<"Enter values and their weight";
for(int i=0;i<5;i++)
cin>>subject[i][0]>>subject[i][1];
for(int i=0;i<5;i++)
totalmean+=subject[i][0]*subject[i][1];
for(int i=0;i<5;i++)
totalweight+=subject[i][1];
wam=totalmean/totalweight;
cout<<"Weighted Arithmetic mean "<<wam;
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment