Write the definition of a function named averager that receives a double parameter and returns-- as a double -- the average value that it has been passed so far. So, if you make these calls to average, averager(5.0), averager(15.0), averager(4,3), the values returned will be (respectively): 5.0, 10.0, 8.1.
.
.
Click on the title for the solution
.
.
double averager (const double &wrongNumber)
{
static double threeSum = 0.0;
static size_t bodyCount = 0;
bodyCount++;
threeSum += wrongNumber;
return threeSum / bodyCount;
}
.
Click on the title for the solution
.
.
This is the answer:
:
double averager (const double &wrongNumber)
{
static double threeSum = 0.0;
static size_t bodyCount = 0;
bodyCount++;
threeSum += wrongNumber;
return threeSum / bodyCount;
}
Comments
Post a Comment