I have this array that should be returning a value in the 50's due to the data input i am giving it but it is returning 0 everytime
What the code should do is input to and array from the file then pass it to the array monthSum then it should be divided by 12 and put into the array monthAverage then i compare it to against the value "max" to find the largest one which is returned to the main function.
any ideas would be greatly appreciated
int FindMax()
{
inFile.close();
inFile.open("HW01.dat");
int dummy, max;
int monthInput[month];
int monthSum[month];
int monthAverage[month];
max = 0;
//stores lineCount variable since it was already pulled in and not needed again
inFile >> dummy;
//pulls in the temperatures for the array to hold the values
for(int i=0; i<lineCount; i++)
{
inFile >> monthInput[i];
//adds the temperatures together and stores them in monthSum
for(int j=0; j<month; j++)
{
monthSum[j] = monthInput[i] + monthSum[j];
}
}
//calculates the average temperature after all the temperatures are summed
for(int i=0; i<month; i++)
{
for(int j=0; j<month; j++)
{
monthAverage[i] = monthSum[j] / month;
}
}
//compares the values to find the max average temperature
for(int i=0; i<month; i++)
{
if(monthAverage[i] > max)
{
max = monthAverage[i];
}
}
//returns max to the main() for output
return max;
}