Run Code
|
API
|
Code Wall
|
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
Silly circular pointer
Zahra_matrix
Diferenciacion e integracion beta 0.1
TraiectorieIdeala
A number is prime or not
Tower of hanoi
543
pangram
combine c++ string with dynamically allocated c array of chars through overloaded add operator
CPPTemplate