I think a big problem is that none of these functions should be prompting for input and displaying output. That is the task of the main function. These should just compute a result based on the arguments and return it.
Code:
char findMonth(int months)
{
int monthNum;
char months[12][10]={
"January","February","March","April","May","June",
"July","August","September","October","November","December"
};
cout<<"Please enter the number of the month"<<endl;
cin>>monthNum;
cout<<months[monthNum][10];
}
Although the signature appears to be incorrect, the intent of this function is to accept the month number from the caller (that's why the function has the argument) and return the name of the month to the caller.
Code:
#include <iostream>
//NB month is zero-based (January = 0, etc)
const char* findMonth(int month)
{
if (month < 0 || month > 11) month = 12;
static const char* monthNames[13] = {
"January","February","March","April","May","June",
"July","August","September","October","November","December",
"Invalid month number"
};
return monthNames[month];
}
//it's up to the caller to decide what to use the function for:
int main()
{
int m;
while (std::cout << "Enter month number: " && std::cin >> m) {
std::cout << "Month #" << m << " is " << findMonth(m - 1) << '\n';
}
}
Similarly for the other functions. I even think that the intended usage of the findMonth functions is:
Code:
std::cout << "The month with the lowest rainfall is: " << findMonth(findLowestRainfall(data)) << '\n';
//etc.