Finding mean as a double

Hi, I'm having trouble understanding how they found the mean of the integers as a double.

The question is as follows:
Given a list of N integers, find its mean (as a double), maximum value, minimum value, and range. Your program will first ask for N, the number of integers in the list, which the user will input. Then the user will input N more numbers.


The solution is this:
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
  #include <iostream>
using namespace std;

int main()
{
	
	int N;
	cout << "Enter N: ";
	cin >> N;
	int acc = 0;
	cout<<"Now enter each value and click 'Enter' after each one \n";
	cin >> acc;
	int minVal = acc;
	int maxVal = acc;
	
	for (int i = 1; i < N; ++i)
	{
		int a;
		cin>>a;
		
		acc+=a;
		if(a<minVal)
		{minVal=a;}
		if(a>maxVal)
		{maxVal=a;}
	}
	cout<<"Mean: "<<(double)acc/N<<"\n";
	cout<<"Max: "<<maxVal<<"\n";
	cout<<"Min: "<<minVal<<"\n";
	cout<<"Range: "<<(maxVal-minVal)<<"\n";
	return 0;
}


What I don't understand is line 27, where they found the mean by using "(double)acc/N". Isn't acc just the very first value entered and not the sum of all the integers? Any help would be appreciated.
acc is not just the first value. Its the accumulated sum. line 21
Thank you!
Topic archived. No new replies allowed.