Temperatures Take the following temperatures and put them into two arrays (one f
ID: 3781722 • Letter: T
Question
Temperatures Take the following temperatures and put them into two arrays (one for high temps and one for low temps). They are in order! December 2016 High Temps - 45, 40, 39, 42, 44, 42, 43, 36, 28, 28, 35, 42, 33, 31, 19, 23, 58, 59, 27, 37, 38, 40, 41, 47, 40, 66, 65, 43, 41, 33, 43 December 2016 Low Temps - 38, 35, 37, 34, 33, 32, 36, 25, 23, 24, 24, 31, 27, 21, 8, 6, 25, 23, 18, 15, 27, 35, 31, 39, 33, 35, 37, 32, 34, 27, 25 Calculate the average high and average low temperatures and display them on the page labeled appropriately Get the top five hottest and top five coldest high temperatures of the month and display them (the day and temperature) Get the top five hottest and top five coldest low temperatures of the month and display them (the day and the temperature) Using loops will make this much easier! Rubric for this assignment: Code is commented and indented: - runs without errors): the date is correct: runs without errors): the averages, highs and lows are correct:Explanation / Answer
#include <stdio.h>
// return average of a given array
double average(int arr[], int size)
{
int i = 0;
// computing sum of array
double sum = 0;
for (i = 0; i < size; i++)
{
sum += arr[i];
}
// computing average and return
return (sum/size);
}
int main()
{
// High temperature for December
int high_temp_array[] =
{45,40,39,42,44,42,43,36,28,28,35,42,33,31,19,23,58,
59,27,37,38,40,41,47,40,66,65,43,41,33,43};
// Low temperature for December
int low_temp_array[] =
{
38,35,37,34,33,32,36,25,23,24,31,27,21,8,6,25,23,18,15,27,35,31,39,33,35,37,32,34,27,25
};
double average_max_temp = average(high_temp_array, 31);
double average_min_temp = average(low_temp_array, 31);
printf("Average max temperature is : %f ", average_max_temp);
printf("Average min temperature is : %f ", average_min_temp);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.