title: Dynamic and static Scoping program differences
body: <pre><code>int x;
  
  int main() {
     x = 14;
     f(); 
     g();
  }
  
  void f() {
     int x = 13;
     h();
  }
  
  void g() {
     int x = 12;
     h();
  }
  
  void h() {
     printf("%d\n",x);  
  }
  </code></pre>
  
  <p>If static scoping is used, what is the result? If dynamic scoping is used, what is the result? </p>
  
  <p>Now if I understand scoping right, the difference between static and dynamic scoping is that static makes variables local to a class. So the value <code>x</code> would be local to <code>void f()</code>, <code>void g()</code> and <code>int main ()</code> and dynamic would make them globally available. I'm just not sure how to apply it to this code. If static scoping was used would it only print the last value (12 from <code>void g()</code>) and dynamic scoping would be using all the values of <code>x</code>?</p>
  
  <p>I'm a little confused on how scoping actually works. I know <code>C</code> uses static scoping though.</p>