Question: Write a function called calcSum that will calculate and return the sum of a specific number of values in an array of integers. The function
Write a function called calcSum that will calculate and return the sum of a specific number of values in an array of integers. The function takes two arguments: an array of integers to be added and an integer that holds the number of values in the array to use when calculating the sum. It returns an integer: the sum of the specified number of values in the array. The function should execute a loop that runs "number of values in the array" number of times. Each iteration of the loop should add a value from the array to a running total (the sum). Once the loop is done executing, the running total (sum) should then be returned.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
