Assume that you collect weather (temperature) data for City of Commerce for 5 days, Mon thru Fri. The data is record in a 1D array. Each day is represented with 3 data points.

Step #1 – Create an array with 15 “unsigned short” items, and fill this array with random numbers from 32 to 120. Let’s call this array temp array.

77 43 56 35 35 33 87 .. .. .. .. .. 65 76 54
In the above array,Monday’s temp readings are 77, 43, 56; Tuesday’s are 35, 35, 33, so forth so on.

Step #2 – Create a structure to keep 1) name of day, and 2) average of temp of this array. Since you will have five days, you need to create an array of struct as depicted below. Each row of this array keep a struct (the day and corresponding average temp of this day, Monday thru Friday) as a struct (gray box of array)

Day Ave




Here Day is name of the day, such as “Monday”, and Ave is float variable and average of this day calculated from temp array. For the first day, (Monday), the average will be average of temp array indexes [0], [1], and [2], Tuesday’s average will be average of indexed [3], [4], and [5]. Fill all averages using data from array with a loop (not manual). Fill out names of days manually, and print the day:ave pairs on screen. The output should be similar to

Monday, average temp with 58.7
Tuesday, average temp with 34.3
Wednesday, average temp with 75.0
Thursday, average temp with 75
Friday, average temp with 65.7

Sample Solution

This question has been answered.

Get Answer