Looping and control structure

#include<stdio.h>
int main()
{
int i=3;
while(i–)
{
int i=100;
i–;
print("%d",i);
}
return 0;
}
My output was coming infinite as 99 will repeat again and again but the answer was just 3 99s i.e. 99 99 99.
How?!

It is because variable i declared inside and outside of while loop are different variables with different scopes.

Variable i declared outside of the the loop is used as counter variable for the loop(it keeps on decrementing until it becomes 0), while one declared inside the loop is used for printing(it is redeclared and reassigned to 100 everytime loop runs).