Question
C++ 4. Running sum of arrays [10 points] Write a function with the following signature: void running_sum(int arr[], int size) This function takes in an
C++
4. Running sum of arrays [10 points]
Write a function with the following signature:
void running_sum(int arr[], int size)
This function takes in an array of int elements and the size of the array. It should replace all elements of the array with the partial sum up to and including that element.
Example
Input array: [1, 2, 3, 4]
Output: The function produces no output, since it returns void. We will be checking that the input array's values have been modified as per the instructions above.
Explanation: Why is the third element of the answer 6? Because in the original array, the first three elements add up to 6. Another way to look at the output is [1, 1+2, 1+2+3, 1+2+3+4]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
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