Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students explore these related Databases questions