/* Demonstrate scoping rules with a simple example Emad Arasteh October 31, 2019 */ #include int foo = 42; void print() { printf("4. Value of foo in print() is: %d\n", foo); } int main() { int foo = 1; printf("1. Value of foo in main() is: %d\n", foo); { int foo = 2; printf("2. Value of foo in block is: %d\n", foo); } printf("3. Value of foo in main() is %d\n", foo); print(); return 0; }