/*
This program declares an array of type int and size 4 (but notice that 
the size can be changed by changing the value of n), reads the array, 
and finds the sum and average of the array. It also shows you how to 
print the memory address of a and its elements.
*/
#include <iostream>
using namespace std;
int main()
{
	int i, sum = 0;
	const int n = 4;
	int a[n];
	cout << "Enter " << n << " integers: ";
	// Read the array:
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		//cout << &a[i] << endl;
	}

	// cin >> a; // NO, don't.
	// cin >> a[i]; // This dies not read the whole array
	/* print memory address of a (base address), which is the 
	memory address of a[0]
	*/
	//cout << "a = " << a << endl; 
	
	/* print memory address of a[0], which is the same as the value
	stored in a.
	*/
	//cout << "&a[0] = " << &a[0] << endl;
	
	
	// Print a (all values of a)
	for (i = 0; i < n; i++)
		cout << a[i] << '\t';
	cout << endl;
	for (i = 0; i < n; i++)
		sum += a[i];
	cout << "Sum = " << sum << endl;
	cout << "Average = " << float(sum)/n << endl;

	return 0;
}
