Some questions on static variables in functions

  1. Write a function which has a single integer parameter and uses static integer variables to keep track of the mean of all values passed to it during the running of a program. It should return the mean so far each time it is called. Test it in a program.

  2. Why can this function only keep a running mean for one stream of values?

Answers to these questions.


Back to notes on statics in functions.