Simple averaging problem

Whats up guys, just got a simple averaging program here. I can't seem to figure out how to have the 5 numbers averaged out. I got the for-loop working fine for the 5 counts since I need 5 numbers to be averaged but I just can't seem to figure out how to store the numbers and then have them averaged out. This is what I have 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

#include <iostream>

using namespace std;

int main()

{
    int count;
    int num;
    double average;

    cout << "Enter 5 numbers to be averaged" << endl;

    for (count = 1; count <= 5; count++)

    {
    cin >> num;

    }
    average = num / 5.0;
    cout << average << endl;
    return 0;

}
you can initialize average with 0 and then, in for
loop, you will increment it with num divided by 5 each time

1
2
3
4
5
6
7
double average = 0;

for(count = 1; count <= 5; count++)
{
         cin >> num;
         average += (num / 5.0);
}
Are you allowed
to use arrays?

i.e.

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
//AverageProgram.cpp
//##

#include <iostream>
using std::cout;
using std::cin;
using std::endl;




int main(){

        int const SIZE=5;
        double setOfNumbers[SIZE]={};
        double average;
        double sum=0;

        
        cout<<"Enter "<<SIZE<<" numbers."<<endl;
        for(int i=0;i<SIZE;i++){
                cout<<"Enter number #"<<i+1<<">>";
                cin>>setOfNumbers[i];
                sum+=setOfNumbers[i];
        }//end for

        average=sum/SIZE;

        cout<<"\n\nNumbers entered "<<endl;
        for(int i=0;i<SIZE;i++){
                cout<<"Number #"<<i+1<<' '<<setOfNumbers[i]<<'\n';
        }//end for
        cout<<"\nSum: "<<sum<<endl;
        cout<<"Average: "<<average<<endl;



return 0; //indicates success 



Enter 5 numbers.
Enter number #1>>6
Enter number #2>>3
Enter number #3>>2
Enter number #4>>27
Enter number #5>>18


Numbers entered 
Number #1 6
Number #2 3
Number #3 2
Number #4 27
Number #5 18

Sum: 56
Average: 11.2
Topic archived. No new replies allowed.