title: Scope of macros in C?
body: <p>How these macros are evaluated? </p>
  
  <pre><code># define i 20
  void fun();
  
  int main(){
    printf("%d",i);
    fun();
    printf("%d",i);
    return 0;
  }
  
  void fun(){
    #undef i
    #define i 30
  }
  </code></pre>
  
  <p>gives output as 2020 but whereas,</p>
  
  <pre><code># define i 20
  void fun(){
    #undef i
    #define i 30
  }
  
  int main(){
    printf("%d",i);
    fun();
    printf("%d",i);
    return 0;
  }
  </code></pre>
  
  <p>gives output as 3030.
  Please Explain. Thanks.</p>