# Thread: Completely stumped on += operator. (5 lines of code)

1. ## Completely stumped on += operator. (5 lines of code)

Code:
```void declare_winner (int temp2[],int counter,int i) {

for(i=0;i<=3;i++){

counter += temp2[i];

} // prints out a WRONG value (358484)

counter = temp2[0]+ temp2[1]+ temp2[2]+ temp2[3]; // prints out the correct value

printf("%d",counter);

}```
I know they're the same to C, but how come one prints out a completely wrong value? I'm really stumped on this. Am i accessing out of bounds using the for loop?

2. Thanks Solved!

3. Where did you get the solution? Just in case anyone else reads this, to me, it looks like the problem is within your for loop. This line in particular:
Code:
`counter += temp2[i];`
. You say the bottom one works correctly,
Code:
`counter = temp2[0]+ temp2[1]+ temp2[2]+ temp2[3];`
. The first can be written like:
Code:
`counter = counter + temp2[i];`
. This equates to
Code:
`counter = counter + temp2[0] + temp2[1] + temp2[2] + temp2[3];`
.

I see in your comment you put the reason as to what the problem is. In the loop, you add the value of counter to counter, and then you add temp2[i]. The other, you just add temp2[i] essentially. Your solution is correct, initialize counter to 0 before you go into the for loop.