Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Weighted Average
//g++ 7.4.0 //Weighted average: calculating weighted average //created by Rezaul Hoque on December 09,2020 //contact at jewelmrh@yahoo.com #include <iostream> using namespace std; int main () { float wa; int sumW=0,sumXW=0; int n=6; //variable int x[n]={70,80,50,90,60,85}; //weights int w[n]={80,120,100,225,135,300}; for(int i=0;i<n;i++) { sumW += w[i]; sumXW +=w[i]*x[i]; } cout<<"The variable and weight are:\n"; cout<<"x"<<"\t"<<"w"; cout<<endl; for (int i=0; i<n;i++) cout<<x[i]<<"\t"<<w[i]<<"\n"; //weighted average wa= sumXW/sumW; cout<<"Weighted average is "<<wa; return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
¡Arriba, Papalotes, Arriba! v2
Christopher-Stellar
5
Gauss 4x4 reducido
DoubleListInt
GenericPacker
E. Bus Number
Finalproject
Estocasticos V1.1
Dar
Please log in to post a comment.