Looping and control structure

int main()
int i=3;
int i=100;
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.

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).