Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1: Complete the function average below which has a parameter temperatur

ID: 3569948 • Letter: Q

Question


Question 1: Complete the function average below which has a parameter temperature that is a 2-dimensional array of hourly temperature measurements for one week. The function must calculate and return the average of all the temperature measurements for the week (one value for the whole week, not values for each day). You may use the constants DAYS and HOURS as needed in the function. The function would be called by a statement something like: x average (data); const int DAYS=7; const HOURS = 24; double data [DAYS] [HOURS]; .. double average(double temperature [] [HOURS]) {

Explanation / Answer

#include <stdio.h>

const int DAYS = 7;
const int HOURS = 24;

double data[DAYS][HOURS];

double average(double temparature[][HOURS]){
   double total = 0.0;
   int i = 0, j = 0;
   for(i = 0; i < DAYS; ++i){
       for(j = 0; j < HOURS; ++j){
           total += temparature[i][j];
       }
   }
   total = total / (DAYS * HOURS);
   return total;
}

int main(){
   // Here Goes the Main
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote