Average

The simplest average function takes a vector of numbers , sums its values, and divides that value by the length of the vector. This is implemented using only base language features.

 

double Average(const double * list, const int & length)
{
  double sum = 0.0;
  for (int i = 0; i < length; ++i) {
    sum += list[i];
  }
  return sum / length;
}
Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 2 mths agoLast active
  • 4Views
  • 1 Following