// Passing an array to a function
#include <iostream>
using namespace std;

double sum(double x[], int);

int main ()
{
  double a[5];

  cout << "Enter 5 reals: ";
  for (int k=0; k<5; k++)
     cin >> a[k];

  double s = sum(a, 5);

  cout << "The sum is " << s << endl;

  return 0;
}

// returns the sum of the first n elements
double sum(double x[], int n)
{
  double t = 0.0;
  for(int i=0; i<n; i++)
       t += x[i];
  return t;
}
