Writing arrays

I need the following program to allow the user to enter up to 100 numbers in an array and print these numbers to the screen, along with the average. However, when I try to run the program with the numbers (15, 20, 25, 30, 35, 40, 10, 89) this is what is printed to the screen.

"There were 89 numbers entered into the array.
15 20 25 30 35 40 10 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89...
Enter up to 100 positive numbers.
The average value of the numbers entered is 77."


This is the function in my program that is causing the problem. If anyone can give me some tips to correct this it would help so much!

1
2
3
4
5
6
7
8
9
10
11
 int FillFunction(double myarray[])
{
	int number, n=0; 
	cout << "Enter up to 100 positive numbers. \n";
	cin >> number;
	while (( number >= 0 ) && (n < MAXSIZE)) {
		myarray[n] = number;
		n++;
		cin >> number;
	}
	return number;
Shouldn't that be return n; ?
Oh yeah, it should be.. everything works fine now, thanks a lot
Topic archived. No new replies allowed.