#include int x = 1; int f(int y) { return x+y; } // static scoping // simulated dynamic scoping with mutation void g() { int savedx = x; // save previous value of x on stack x = 2; // temporary new value of x printf("%d\n", f(0)); x = savedx; // restore saved value. } int main() { int x = 2; g(); printf("%d\n", f(0)); return 0; }