It used to be mandatory to declare locals up front in C, presumably because it is easier to implement a compiler when that is the case.
These days, the compiler is actually "sufficiently advanced" that this does not make any difference for POD types. Because of this, the question boils down to readability and matters of taste in C.
In C++, however, declaring of locals imply things about the execution of the relevant constructor and destructor and it can have bearing on whether or not the compiler will be able to employ certain optimizations. This means that declaring them all at the top is not equivalent to declaring them on demand, rendering your question mostly invalid for C++.
In C++, declare the variables when it is semantically correct for the program you are trying to write. (And on top of that there are also matters of readability and taste)