View the step-by-step solution to:

# You all know how to use loop to compute a sum of all values in the array. Here's an example: int arr[lO] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int sum =...

-----------------------------------------------------------------------------------

You all know how to use loop to compute a sum of all values in the array. Here's an example: int arr[lO] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = O; for (int i=0; i &lt; 10; i++)
sum += arr[i]; The addition of all elements can be done using recursion. Remember, with recursion, at each step you need to make the problem smaller. In case
of the sum of the array elements, you can say that the sum of all elements is the sum of lst element and the rest of the array. Did you notice that
&quot;sum of the rest of the array&quot; is the same problem,just 1 element smaller? I want you to write and use recursive function to sum the elements of the array. The function can take 2 or 3 parameters, depending on how
comfortable you are with pointers. If you want the simpler solution, your function can take array, index of the starting element and the total size of the array.
If you know how to pass the address of the next element (instead of the array itself, which is address of the ﬁrst element), then you do not need
to pass the index of the next element in the array (but the size should not be the size ofthe initial array but the remaining size). Handle the input in a separate function that prompts user to enter a speciﬁc number of elements (number of elements should be one of the
parameters to the input function). The size of the array can be whatever you want it to be.

#include &lt;iostream&gt; using namespace std ; int rec_func ( int *arr, int n) {    ... View the full answer

#include&lt;iostream&gt;
using namespace std;
int call_sum(int arr, int N)
{
if (N &lt;= 0)
return 0;
return (call_sum(arr,N - 1) + arr[N-1]);
}
int main()
{
int sum = 0,N;
cout&lt;&lt;&quot;Enter...

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents