Array Assignment Help

Hello, I have been assigned a program where you need to ask the user how many random numbers they want to display, generate that many random numbers, loop them into an array and then display the numbers that are in the array. I have all of that finished.

Now for the problem.. The end of the assignment is to display the lowest and highest number in the array along with the average and total of the numbers in the array. How can I do this. Sorry if this seems like an easy question. I generally get stumped on the easiest parts of assignments.

Thanks for your help.
Here is my code so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  #include <iostream> 
#include <cstdio>          
#include <cstdlib>    
#include <ctime>
using namespace std;
int main ()
	{
		int randNum;
		int x = 0;
		int y = 0;
		srand (time(0)); //Initializes random number generator

		cout << "How many random numbers would you like to generate?" << endl;
			cin >> randNum; //Gets users input on how many random numbers to generate
			
		int array[randNum]; //Declares size of the array.
	
		for(x = 0; x < randNum; x++) { //Loops through the array passing on the random numbers into the array
			array[x] = rand() % 500 + 1;
		}
		
		for(y = 0; y < randNum; y++) { //Loops through the array displaying all of the random numbers generated
			cout << array[y] << " ";
		}
		return 0;
	}
	
	//How can I Display the lowest and highest number in the array along with the average and total of the numbers in the array? 
1
2
3
4
5
6
int sum =0;
for(int i = 0; i < randNum; i++) 
{
    sum = sum+ array[i];
}
cout << "total= " << sum;
Topic archived. No new replies allowed.