struggling now!!

Pages: 12
I hope your still checking this thread so that you may find my advice helpful. There is no need for an array to calculate the average; you just need to accumulate the sum of the numbers each step of the way.

I would start with the inner-most loop and work outward. For example, this will process one of the lists:
1
2
3
4
5
6
7
8
9
10
int count, number, sum = 0;                       // note that sum is initialised to 0
cout << "Enter the number count: ";
cin >> count;
for( int i = 0; i < count; ++i )
{
    cout << "Enter number: ";
    cin >> number;
    sum += number;
}
cout << "Average = " << ( sum / count ) << endl;  // output the average1 


1 Note that the average will always be a whole number, due to integral division.
Last edited on
Topic archived. No new replies allowed.
Pages: 12