Program that declares a three dimensional array to store the temperature of a month. The temperature is entered for morning, moon and evening for each day. The first dimension should be used to for three timings of a day, 2nd should be used for 7 days of a week and 3rd dimension should be used for four week of a month. The program should input the temperatures and then display the maximum, minimum and average temperature of a whole month.
#include <iostream>
using namespace std;
const int c = 2;
const int w = 7;
int main()
{
int temp[c][w];
cout << "Enter all temperatures \n";
for (int i = 0; i < c; ++i)
{
for(int j = 0; j < w; ++j)
{
cout << "City " << i + 1 << ", Day " << j + 1 << " : ";
cin >> temp[i][j];
}
}
for (int i = 0; i < c; ++i)
{
for(int j = 0; j < w; ++j)
{
cout << "City " << i + 1 << ", Day " << j + 1 << " = " << temp[i][j] << endl;
}
}
return 0;
}
Comments
Leave a comment