Thanks for the quick replies
I'm pretty sure there is a way to set all the values of my daily_temp array to 0 without making that FOR loop...any help on that would also be appreciated
Here's the code...not fully complete yet but enough:
Code:
#include <iostream>
using namespace std;
int getMonth();
int getYear();
int getTemps(int month, const int monthday[], double daily_temp[]);
void BubbleSort(double[], int array_lengh, int passes, int day_num);
void largestValues(double daily_temp[31], int days);
void smallestValues(double daily_temp[31]);
int main()
{
char station[51];
int month = 0, year, day_num, passes;
const monthday[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, '\0'};
double daily_temp[31];
for(int a = 0; a < 31; a++)
{
daily_temp[a] = 0;
}
cout << "Please enter station name: ";
cin.getline (station, 51, '\n');
day_num = monthday[(month-1)];
month = getMonth();
year = getYear();
passes = getTemps(month, monthday, daily_temp);
BubbleSort(daily_temp, 31, passes, day_num);
largestValues(daily_temp, day_num);
smallestValues(daily_temp);
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;
}
int getTemps(int month, const int monthday[], double daily_temp[])
{
int n, day_num = 1, pass_num = 0;
double total_temps = 0, avg_temp = 0, days;
days = monthday[(month-1)];
for ( n=0; n < 5; n++)
{
cout << "Please enter day " << day_num << "'s highest temperature: ";
cin >> daily_temp[n];
total_temps += daily_temp[n];
day_num++;
pass_num++;
}
return pass_num;
}
void BubbleSort(double daily_temp[31], int, int, int)
{
double temp_move;
int s = 35;
for(int b = 0; b < s; b++)
{
for(int u = 0; u < s-b; u++)
{
if (daily_temp[u] > daily_temp[u+1])
{
temp_move = daily_temp[u+1];
daily_temp[u+1] = daily_temp[u];
daily_temp[u] = temp_move;
}
}
}
}
void largestValues(double daily_temp[31], int day_num)
{
cout << "Largest values are: " << daily_temp[day_num] << " and " << daily_temp[day_num-1];
}
void smallestValues(double daily_temp[31])
{
cout << "Smallest values are: " << daily_temp[0] << " and " << daily_temp[1];
}
Thanks for the help,
...Dan