Help with programing project.

I am required to make a program which asks the user for a series of values one at a time. When the User enters the integer 0, the program displays the following information:
-The number of integers in the series, not including 0.
-The average of the integers.
-The largest integer and the smallest integer in the series.
-The difference between the largest and smallest integers.

At the moment, I cannot post what I have so far, as is is on a different computer and I don't have a drive. I would greatly appreciate any help available. I will try to post what I have so far ASAP. Thank You.
Hey I'm fairly new to c++ so my code may not be the most efficient but here's something to go off of. Hope it helps!
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>

using namespace std;

double findaverage(int intarray[],int arraysize)
{
	int total = 0;
	for (int x = 0; x < (arraysize - 1); x++)
	{
		total += intarray[x];
	}
	return ((double)total/(arraysize - 1));
}

int findsmallest(int intarray[],int arraysize)
{
	int smallest = intarray[0];

	for (int x = 1; x < (arraysize - 1); x++)
	{
		if (intarray[x] < intarray[x-1])
		{
			smallest = intarray[x];
		}
	}
	return smallest;
}

int findlargest(int intarray[],int arraysize)
{
	int largest = intarray[0];

	for (int x = 1; x < (arraysize - 1); x++)
	{
		if (intarray[x] > intarray[x-1])
		{
			largest = intarray[x];
		}
	}
	return largest;
}

void pause(void)
{
	cout << "Press any key to exit";
	cin.ignore();
	cin.get();
}

int main (void)
{
int user_input = 1;
int arraysize = 0;
int intarray[500];

do
{
cout << "Please input a number, 0 to stop (500 max numbers)" << endl;
cin >> user_input;
intarray[arraysize] = user_input;
arraysize++;
} while (user_input != 0);

cout << "The number of ints entered is " << (arraysize - 1) << endl;
cout << "The average is " << findaverage(intarray,arraysize) << endl;
cout << "The smallest is " << findsmallest(intarray,arraysize) << endl;
cout << "The largest is " << findlargest(intarray,arraysize) << endl;
cout << "The difference between the largest and smallest integers is " << (findlargest(intarray,arraysize) - findsmallest(intarray,arraysize)) << endl;

pause();

return 0;
}
I'll try it, thanks so much!
Topic archived. No new replies allowed.