I have this multi-dimensional array. There are 12 rows, each represents the months, and 2 columns, the 1st column represents the lowest temperature and the 2nd column represents the highest temperature.
I need to find the lowest temperature in only the first column and the highest in only the 2nd column. How would I go about this?
This takes in the temperatures. LOHI = 2, MONTHS = 12, LOW = 0, HIGH = 1
change all i to j. I was distracted midway and made a mistake.
In low variable you store the value of lowest temperature, not index, so you should just do std::cout << "Lowest: " << low;
I figured, so I changed them. However, that did not help me find the lowest value. I am making sure that the lowest input is not in temp[0][0] but it keeps returning that for the value of low.
Maybe it has something to do with initializing low to = temp[0][0]? And the value of low is never changed?
Here's the whole program:
[code]
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const int MONTHS = 12;
const int LOHI = 2;
enum{LOW, HIGH};
void PopulateTemp(int temp[][LOHI]);
int ReadTemp(string prompt);
int FindLow(const int temp[][LOHI]);
void ReportTemp(const int temp[][LOHI], int low);
template <class T>
bool Read(T& d);
int main()
{
int temp[MONTHS][LOHI];
int low;
low = FindLow(temp);
PopulateTemp(temp);
ReportTemp(temp, low);
return 0;
}
It asks the user to enter a low and high temperature for each month and at the end I'm suppose to output the lowest temperature under the low column and the highest temperature under the high column.