according to me following while loop should be infinite but it runs only thrice
main()
{
int i=3;
while(i--)
{
int i=100;
The variable i that checks the condition is the one you declared in main() not the one inside the loop.
Both are different variables you are confusing them as one, the compiler doesn't get confused as easily as you were.
Inside the loop i refers to the one you declared inside the { } but outside the { } the i refers to the one declared in main()