Code:
int a; //Let us call this a1, at file scope
int main() {
int a; //Let us call this a2; it is local, in local scope. a1 is not in scope
while (rand() < 10000) {
a = a + 2; //This uses a2; it is nonlocal to this block, but it has local scope and is currently the only a in scope
int a; //Let us call this a3; it is local, in local scope. a2 is now not in scope, let alone in local scope
a = a + 2; //This must use a3, as it is the only a in scope.
} //a3 no longer in scope, a2 once again in scope
a = a + 2; //This must use a2, as it is the only a in scope.
}
//Poor a1, never used
I think that covers the interesting cases for the question.