ok so I have a filled array and wish to compare the numbers within the array to determine the Highest and the Lowest number
now I know I need a for loop for this but am unsure how to implemented this can someone point me in the right direction?
void get_hrTmps (int hr_tmps[],int tmp_num); //function for user input
double ComputeAverageTemp(int hr_tmps[],int tmp_num);//add the individual array element and then avereage them
void DisplayTemperatures(int hr_tmps[], int temp_num);
#include <iostream>// for cin,cout
usingnamespace std;
int main ()
{
constint tmp_num = 24 ;//constant for 24 hours
int hr_tmps[tmp_num];//array to hold the hours
get_hrTmps(hr_tmps,tmp_num);//function call fdor input
ComputeAverageTemp(hr_tmps,tmp_num);//function call to add the individual array element and then avereage them
DisplayTemperatures( hr_tmps, tmp_num);
return 0;
}
void get_hrTmps (int hr_tmps[],int tmp_num)//input function
{
cout<<"please enter a temp for each hour of the day\n please use only #'s between -15 and a 130\n";
for (int x=0; x<tmp_num; x++)
cin>>hr_tmps[x];
}
double ComputeAverageTemp(int hr_tmps[],int tmp_num)//calculation function
{
int total=0;
double average;
for (int x=0;x<tmp_num;x++)
total=total+hr_tmps[x];
average=total/24;
return average;
}
void DisplayTemperatures(int hr_tmps[], int tmp_num )//output function
{
for (int x=0;x<tmp_num;x++)
cout<<hr_tmps[0-23]<<endl;
}
this is the code thus far . there are errors in this version but have been corrected (this is the only access i have to the code at the moment((at work))). I haven't written the function for the comparison of the highest and lowest yet as I have no clue yet .what i want to do is compare the array for the highest and lowest number.