Please send questions to
st10@humboldt.edu .
/*--------------------------------------------------
created by st10 at Mon Apr 23 09:35:54 PDT 2007
--------------------------------------------------*/
#include <iostream>
#include <cmath>
using namespace std;
/*--------------------------------------------------
Contract: sum_contents : double[] int -> double
Purpose: compute and return the sum of the <size>
values in <numbers> array.
Examples: if const double SIZE1 = 4; and
double arr1[SIZE1] = {1.5, 2, 0.3, 5.46};, then
sum_contents(arr1, SIZE1) == 9.26
if const double SIZE2 = 0; and
double arr2[SIZE2] = {}; then
sum_contents(arr2, SIZE2) == 0
--------------------------------------------------*/
double sum_contents(double numbers[], int size)
{
double sum_so_far = 0;
int index = 0;
while (index < size)
{
sum_so_far += numbers[index];
index++;
}
return sum_so_far;
}