Question: Problem Statement: (solve by c language using if or switch and 1 loop): Given a sequence , an n -moving average is a new sequence
Problem Statement: (solve by c language using if or switch and 1 loop):
Given a sequence , an n-moving average is a new sequence defined by taking the arithmetic mean of subsequences of n terms:

As an example, consider the following table:
| Day | Temperature (Celcius) | 5-Day Moving Average (MA) | Value of i | Values Used in Computing MA |
| 1 | 21 |
|
|
|
| 2 | 22 |
|
|
|
| 3 | 20 |
|
|
|
| 4 | 18 |
|
|
|
| 5 | 19 | 20 | 1 | Average of Days 1 through 5 |
| 6 | 21 | 20 | 2 | Average of Days 2 through 6 |
| 7 | 22 | 20 | 3 | Average of Days 3 through 7 |
| 8 | 20 | 20 | 4 | Average of Days 4 through 8 |
| 9 | 22 | 20.8 | 5 | Average of Days 5 through 9 |
| 10 | 23 | 21.6 | 6 | Average of Days 6 through 10 |
The user will supply data to your program using the numerical keys on the keyboard. Your program should check if the provided input is a positive integer. If it is so, it will consider it as the next data item in the sequence and update the moving average. The program terminates when the user enters a negative integer number. The length of the subsequence is fixed and it is equal to 5 (i.e., n = 5). The following is a detailed sample run of the program:
Sample Run 1

i+n-1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
