Markl write a declaration for a two-dimenSional array named temperature readings
ID: 3821656 • Letter: M
Question
Markl write a declaration for a two-dimenSional array named temperature readings that 4) Bonus 2 readings. For simplicity. assume that a as 30 days. stores one month of hourly temperature represent hours of the The rows of the array should represent day of the month; the columns should day. Using this array, write a program fragment that computes the daily average of temperature for each day of the month (average of all hourly temperature of each day of the month. Hint The daily average of temperature needs to be stored in a one-dimensional array.Explanation / Answer
#include <stdio.h>
int main()
{
int temparature_readings[30][24]; //array to store the each dau]y hourly temparature
float av[30]; //array to store the average temparature of each day
int i,j,m;
float sum,avg;
m=0;
sum=0;
avg=0;
for(i=0;i<30;i++) //taking each days temparture input from the user
{
printf("DAY %d ",i+1);
for(j=0;j<24;j++)
{
printf("Enter the temparature ");
scanf("%d",&temparature_readings[i][j]);
}
}
for(i=0;i<30;i++) //calculating the average for each day
{
for(j=0;j<24;j++)
{
sum=sum+temparature_readings[i][j];
}
avg=sum/24;
av[m++]=avg;
sum=0;
}
printf("The details are "); //dispalying total day and their temparature
for(i=0;i<30;i++)
{
for(j=0;j<24;j++)
{
printf("%d ",temparature_readings[i][j]);
}
printf(" ");
}
printf("Average Temparature "); //Displaying the average temparature for each day
for(i=0;i<30;i++)
printf(" Day %d %f ",i,av[i]);
return 0;
}