Please send questions to
st10@humboldt.edu .
/*--------------------------------------------------
created by smtuttle at Fri Nov 5 08:44:18 PDT 2010
--------------------------------------------------*/
#include <iostream>
#include <cmath>
using namespace std;
/*--------------------------------------------------
signature: sum_array : double[] int -> double
purpose: expects an array of numbers and how many numbers are
in the array, and produces the sum of those numbers
Examples:
const int NUM_WTS = 5;
double my_list[NUM_WTS] = {10, 20, 3, 4, 100};
sum_array(my_list, NUM_WTS) == 137
--------------------------------------------------*/
double sum_array(double values[], int num_values)
{
double sum_so_far = 0;
int index = 0;
while (index < num_values)
{
sum_so_far = sum_so_far + values[index];
index++;
}
return sum_so_far;
}