Answer:
#include <iostream>
using namespace std;
typedef double* temperatures;
double avg(array t, int length);
double min(array t, int length);
double max(array t, int length);
int main()
{
cout << "Please input the number of temperatures to be read." << endl;
int num;
cin >> num;
temperatures = new double[num];
for(int i = 0; i < num; i++)
{
cout << "Input temperature " << (i+1) << ":" << endl;
cin >> temperatures[i];
}
cout << "The average temperature is " << avg(temperatures, num) << endl;
cout << "The highest temperature is " << max(temperatures, num) << endl;
cout << "The lowest temperature is " << min(temperatures, num) << endl;
}
double avg(array t, int length)
{
double sum = 0.0;
for(int i = 0; i < length; i++)
sum += t[i];
return sum/length;
}
double min(array t, int length)
{
if(length == 0)
return 0;
double min = t[0];
for(int i = 1; i < length; i++)
if(t[i] < min)
min = t[i];
return min;
}
double max(array t, int length)
{
if(length == 0)
return 0;
double max = t[0];
for(int i = 1; i < length; i++)
if(t[i] > min)
max = t[i];
return max;
}
Explanation:
The C++ program get the array of temperatures not more than 50 items and displays the mean, minimum and maximum values of the temperature array.