Please send questions to
st10@humboldt.edu .
/*--------------------------------------------------
created by st10 at Wed Oct 22 12:13:58 PDT 2003
--------------------------------------------------*/
#include <iostream>
#include <cmath>
using namespace std;
/*--------------------------------------------------
Contract: sumArray : double[] int -> double
Purpose: Sum the first size elements in array numArray.
Examples: for double vals[3] = {3.1, 7, 18.8},
sumArray(vals, 3) == 28.9
sumArray(vals, 0) == 0
sumArray(vals, 2) == 10.1
CS 131 - Lecture 9-2 - 10-22-03
By: Sharon M. Tuttle
last modified: 10-23-03 (this opening comment block,
and use of const before array parameter
declaration)
--------------------------------------------------*/
double sumArray (const double numArray[], int size)
{
double total = 0;
for (int i = 0; i < size; i++)
{
total += numArray[i];
}
return total;
}