Okay, so I just got some help on how to find the average of 30 randomly generated numbers. The next thing I would like to do however is a little trickier, I think. I would like to display the highest randomly generated number in the equation.
Here is what i have so far.
/*********************************
Name: Roger Clemons
*********************************/
#include <iostream>
#include <cstdlib>
using namespace std;
#include <math.h>
void get_range(int &a, int &b)
{
cout << "Enter the lowest temperature range: ";
cin >> a;
cout << "Enter the highest temperature range: ";
cin >> b;
}
int main()
{
int low = 0;
int high = 0;
const int SEPTEMBER = 30;
int random = -1;
int randomArray[SEPTEMBER];
double sum = 0;
get_range(low, high);
cout << endl;
cout << "Low = " << low << endl;
cout << "High = " << high << endl;
int range=(high-low)+1;
for (int i = 0; i < SEPTEMBER; i++)
{
random = low + int(range*rand()/(RAND_MAX + 1));
randomArray[i] = random;
sum += randomArray[i];
}
cout << "Average = " << sum/SEPTEMBER << endl;
return 0;
}
So now all i would like to do is display the highest number in the array, anyone that is willing to help that would be awesome. Thanks!