For a class I am taking I need to produce 1000 random numbers and store them in an array. I am totally lost and need some help. If someone can get me started on the program it would help me. Also, i need to write a function to find the array's max, min, and average values.

Did you search for previous answers to this common problem?

> I am totally lost and need some help.
I'm going to assume that you've successfully completed some previous assignment, and that the idea of being "totally" lost is an exaggeration.

For example, could you write a program which printed 1000 random numbers. It would be a big start, and show us that you're not looking for a free lunch.

See the readme's at the top of the forum.

I'm also pretty sure that your professor must have given you a specific range of which to get the 1000 numbers. By that I mean...is it a range of numbers between 1 & 5 billion??? Some steps for you and as brought out by Salem...we'll not do your assignment, but we'll guide you and when you get burned out and stuck, we'll try out best to bail you out. A few things:
1. First you'll need to create to use a C++ random generator function. i.e.

srand((unsigned int)time(NULL));

2. You'll need to create an array to store the 1000 numbers. i.e.

mynumbers[1000]

3. The average:

(Sumofnumbers/mynumbers)

4. For the maximum and minimum:

min = 32767
max = -32767
for (i=0; i<count; i++)
{
if(number[count]>max)
max = number[count];
if (number[count]<min)
min = number [count];
}//end for i
cout<<"Max = "<<max<< "and Min = "<<min<<endl;

5. Before posting in the future, chances are that your assignment has been addressed. Please search the forums for similar programs and see if you understand it. Also read the FAQ and Forum Rules to get aquainted with the forum. Welcome aboard and hope you enjoy it. Please do read up on arrays.

i have figured out the majority of the program but i just got stuck. so far i have

#include <iostream>
#include <cmath>
using namespace std;

int line(int, int);
int average(int, int);

int main()
{
	int array[1000], arrMax, arrMin, size=1000, seed, i;
	srand(seed);



	line(array[i], size);
	average(array[i], size); 

	cout << array[i];

	return 0;
}

int line(int array[], int size){
	int i;

	for (i=0; i < size; i++){
		array[i]=rand();
		cout << array[i];

	}
	return 0;

}

int average(int array[], int size){
	int sum, i, number;
	double average;

	for (i=0; i< size; i++){
		number = array[i];
		sum=array[i] + number;
	}
	return average = sum/size;

}

I do not know what libraries to include and what to do next. If I can get some advice it would be great!

Your functions don't seem too right & you may wanna have #include<cstring>

Also, where is your random number generator to get the numbers, or will the user input the numbers??? I doubt that the numbers will fall out of the sky and go into you're computer....try a little harder please. Again i ask....I'm also pretty sure that your professor must have given you a specific range of which to get the 1000 numbers. By that I mean...is it a range of numbers between 1 & 5 billion??? What should be the highest and the lowest number?

> int line(int, int);
If you make this match your function definition, that would be an improvement.

> line(array, size);
To pass an array to a function, it's just the array name, like so
line(array, size);

> cout << array;
Use the same kind of for loop you use in your functions.

Also, you should use "srand" so that your output isn't the same every time you run the program. as zandiago shows above...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.