The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Running Average Problem Description:
Given a list of n measurements m1, m2, A????1 , mn
the average measurement value is defined as ???????? = ??1 + ??2 + ? + ???? ??
We are interested in taking the average value of incoming measurements without having to store all previous measurements in memory.
This can be accomplished in the following way (using 3 and 4 measurement values as an example) ?????3? = ??1 + ??2 + ??3 3 => 3?????3? = ??1 + ??2 + ??3 ?????4? = ??1 + ??2 + ??3 + ??4 4 = 3?????3? + ??4 4
In general, given the nth measurement value ???????? , and a new measurement value mn+1, the new average can be found by ?????????+?1? = ?? ? ???????? + ????+1 ?? + 1 This is known as a running average.
(a) Write a C program that:
(i) Prompts the user for a measurement value.
(ii) Displays the current value for the running average.
(iii) Prompts the user for the next measurement value (repeating the previous steps 10 times).
(b) Test your program using the following values Entry Number Measurement Value Running Average Output
| Entry Number | Measurement Value | Running Average Output |
| 1 | -68.47 | -68.47 |
| 2 | 94.11 |
12.82 |
| 3 | 91.42 | 39.02 |
| 4 | -2.9 | 28.54 |
| 5 | 60.04 | 34.84 |
| Â | Â | Â |
Â
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll