Er, my bad... I don't think the second example would work as expected either. I think it would create a second voltageraw that would only exist in the for loop, and outside of the loop, you'd be accessing the original voltageraw (which was not changed during the loop).
This is why I always consider it best practice to declare my variables at the beginning of my function rather than later in the code, so that they're all declared in an easy to find spot and I don't get tripped up on scoping rules.
This will work:
int i, voltageraw;
for( i=0, voltageraw=0 ; i<20; i++)
{
// stuff
}