Answer:
double averager (double &newNumber)
{
static double sum = 0.0;
static int counter = 0;
counter++;
sum += newNumber;
return sum / counter;
}
Step-by-step explanation:
This exercise is for you to understand how to use variables in functions that have scope outside of the function. The static keyword before a initialising a variable whether int or double or float or string, place the variable on the STATIC MEMORY. This means that when the function ends, those static variables are still usable and can be manipulated with the same stored values. So when the function sees the
static double sum = 0.0;
for the second time it IGNORES it and continues with the previously stored value.