1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//Global Variables...4 NBA Players with Points Per Game for the previous 4 games...
string names [4]={"Lebron James", "Dwayne Wade", "Paul George", "Kevin Durant"};
double points [4][4]= {{36,37,29,38},
{15,14,17,24},
{22,18,0,26},
{27,27,23,38}
};
//Function that will get the total of points scored by all 4 players...
void getTotal()
{
int r,c;
double sum;
for (r=0; r<4; r++)
{
sum=0;
for (c=0; c<4; c++)
sum=sum+points[r][c];
}
//Function that will get the average points scored by all 4 players...
void getAverage()
{
int r,c;
double sum, sum1;
for (r=0; r<4; r++)
{
sum=0;
for (c=0; c<4; c++)
sum=sum+points[r][c];
sum1=sum/16;
cout<<"The average is " <<sum1;
}
}
//Main Program
}int main()
{
getTotal();
getAverage();
return 0;
}
|