The compiler is not that "dumb" and will know that you mean to use a variable that is initialized to 0 in the loop. The above a is different. The compiler can't figure out why you defined a twice. It is probably a wrong input, so an error will be reported.
C++ variable scope problem
Similar to the concept of global variables and local variables.
A variable only works in the middle of "{}". Once the curly brackets are released, the variable will be automatically deleted.
The compiler is not that "dumb" and will know that you mean to use a variable that is initialized to 0 in the loop. The above a is different. The compiler can't figure out why you defined a twice. It is probably a wrong input, so an error will be reported.