title: Accessing the global variable when global and local variables have same name
body: <p>I have some doubt on below code</p>
  
  <pre><code>  #include&lt;stdio.h&gt;
     int i=6;
      int main()
       {
        int i=4;
        {
         extern int i;
         printf("%d",i); //prints 6
        }
        printf("%d",i); //prints 4
       }
  </code></pre>
  
  <p>we know that <code>extern</code> keyword says compiler, the variable is somewhere outside. So the question is why the <code>extern</code> keyword is accessing the global <code>i</code> variable but not the <code>i</code> variable which is within the main function? I was thinking there must be a contradiction because both variables are available to the inner braces as global variable.  So does extern keyword access the variable which is outside the function or does it also access the variable which is outside the braces.</p>