
Mike S.
asked 09/06/17Array question
int sum(int a[], int n): Return the sum of the elements in a given array a of size n.
More
1 Expert Answer

Andy C. answered 10/16/17
Tutor
4.9
(27)
Math/Physics Tutor
//* potential overflow: better use long int
function long sum ( int a[], int n)
{
long lSumReturn = 0;
for (int iLoop=0; iLoop<n; iLoop++)
{
iSumReturn += a[iLoop];
}
return(iSumReturn);
}
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Tim C.
09/06/17