Alright so here's my problem. I am doing this assignment where we read in the temperatures from every day of the month. I have sorted out most of the stuff we have to do but one part we have to make a function that will sort the values from smallest to largest. I somehow need to transfer my array from one function into this other function.
Here is my code so far...Sorry about there not being comments..haven't gotten around to them yet.
What I want to do is transfer the daily_temp array to the BubbleSort Function (which has not been created yet):
Thanks for any help you can give,Code:#include <iostream> using namespace std; int getMonth(); int getYear(); void getTemps(int month, const int monthday[]); int main() { char station[51]; int month, year; const monthday[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, '\0'}; cout << "Please enter station name: "; cin.getline (station, 51, '\n'); month = getMonth(); year = getYear(); getTemps(month, monthday); cout << station; cout << month; cout << year; return 0; } int getMonth() { int month_num; cout << "Please enter the month number: "; cin >> month_num; return month_num; } int getYear() { int year_num; cout << "Please enter the year number: "; cin >> year_num; return year_num; } void getTemps(int month, const int monthday[]) { int n, day_num = 1, pass_num = 0; double daily_temp[31]; double total_temps = 0, avg_temp = 0, days; days = monthday[(month-1)]; for ( n=0; n < days; n++) { cout << "Please enter day " << day_num << "'s highest temperature: "; cin >> daily_temp[n]; total_temps += daily_temp[n]; day_num++; } }
...Dan



LinkBack URL
About LinkBacks


