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
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started