Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
| Output: |
sum. The function
sums integers from start and end. For example,
sum(2,5) will return 14, because we have 2+3+4+5 = 14.
Fill out the blank.
int sum(int start, int end)
{
if( start > end )
return -1; // error!
if( )
return end;
else
return start + sum(start+1, end);
}
We already wrote a working version.
|
|
calcspace! calcspace should
be recursive this time. Of course, your new
calcspace should be functionally equivalent to the original one.
Don't change the main function.
~/bin/submit -c=IC210 -p=hw25 hw.cpp