Question: C++ Write a recursive function named summer that takes two parameters - an array of doubles and the size of the array - and returns
C++
Write a recursive function named summer that takes two parameters - an array of doubles and the size of the array - and returns the sum of the values in the array. The size parameter does not have to be the actual size of the array. It will be at the top level, but at the lower recursive levels it can be the size of the sub-array being worked on at that level.
Don't use any loops when writing your recursive functions. If you do, there's a very good chance your function won't be truly recursive. Also don't use any static variables.
The file must be called: summer.cpp.
test case:
#include
const double EPS = 0.00001;
double array[] = {7.2, 4.32, 16.1, 0.2, 8.0};
double result = summer(array, 5);
ASSERT_TRUE(fabs(result-35.82) < EPS);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
