Write a program that uses two dimensional array to store the highest and lowest temperatures of each month of the year. The program should output the average high, average low, and the highest and lowest temperatures of the year. Your program must consist of the following functions:
a. Function getData: This function reads and store data in the two dimensional array.
b. Function averageLow: This function calculates and returns the average low temperature of the year.
c.Function averageHigh: This function calculates and returns the average high temperature of the year.
d. Function indexHighTemp: This function returns the index of the highest high temperature in the array.
e.d. Function indexHighTemp: This function returns the index of the lowest low temperature in the array.
(This function must have all the appropriate parameters)
Here is my code guys. I don't know how to convert this to function. I hope someone can help with this. I badly need it. Thank you.
cout << endl;
cout << "The highest temperature of the year is: " << highest << endl;
cout << "The lowest temperature of the year is: " << lowest << endl;
Line 24: Why are you using puts() if you're writing C++? That is a C function.
Line 66,70: temp[c-1][0] and temp[c-1][1] are going to cause an out of bounds reference when c = 0.
Line 70: Your second subscript on the right hand side of the comparison is wrong. Should be: if(temp[c][1] < temp[c-1][1])
As for converting this to use functions, do you know how to write functions?
Start by writing a function declaration for each of the required functions. Think about the arguments you will need to pass to the function and what you need to return from each function.
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.