Question: This assignment should be completed using a while loop or for loop. Fill in the accumulate method so that it adds all the numbers between
This assignment should be completed using a while loop or for loop. Fill in the accumulate method so that it adds all the numbers between start and stop with an increment of step.
Assumptions:
Start < Stop
Step 0
Examples:
accumulate(1, 4, 1);
1+2+3+4 = 10
accumulate(3, 5, 2);
3+5 = 8
accumulate(3, 5, 3);
= 3
accumulate(-1,3,2);
(-1)+1+3 = 3
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
