a.
This is close, but remember we start counting at 0, not 1, so this
does the sum from 0, 1, ..., n-1
b.
Here we're not updating sum every time through the loop, so each time
we access sum in
temp = sum + (i+1)
the value will still be 0. The final value of temp (and therefor sum)
when this code finishes will just be n.
c.
Here we're updating sum, but we're not accumulating. Instead, each time
sum will just get i+1. Again, when we're done, sum will just be n.
d.
This is the same as c., except now we've broken it into two steps, first
assigning (i+1) to temp and then temp to sum