Answer SL48

PS C:\Source>gcc sumVersion8.c 
PS C:\Source>a
sum of 1..10: 55
sum of 1..5: 70
PS C:\Source>

Comments:

We've seen this problem before: the sum of 1 to 5 is greater than the sum of 1 to 10.

Now the variable sum in the function is implemented in static memory and so retains its value across calls. Sometimes this is useful, but not here.



Back to Puzzle Home