I was going through scope rules questions and all and then got a code snippet, below:
#include <stdio.h>
int main()
{
int x = 1, y = 2, z = 3;
printf(" x = %d, y = %d, z = %d \n", x, y, z);
{
int x = 10;
float y = 20;
printf(" x = %d, y = %f, z = %d \n", x, y, z);
{
int z = 100;
printf(" x = %d, y = %f, z = %d \n", x, y, z);
}
}
return 0;
}
If I change the last print to:
printf("x = %d, y = %d, z = %d \n", x, y, z);
I get the following output, which I don't understand: (Ideone link)
x = 10, y = 0, z = 1077149696
So, could you explain why is z printing that value?