title: extern keyword usage
body: <p>I have three programs in which I am using <code>extern</code> keyword. I am not able to understand the result. Below are three examples:</p>
  
  <p>Example 1: I was expecting that below code will give compilation error that multiple declaration of <code>k</code>. But it works fine?</p>
  
  <pre><code>int k; //works fine
  extern int k = 10;
  
  void main()
  {
      cout&lt;&lt;k&lt;&lt;endl;
      getchar();
  }
  </code></pre>
  
  <p>Example 2: When I am trying to initialize "k" in above example compiler gives error. Why?</p>
  
  <pre><code>int k = 20; //error
  extern int k = 10;
  
  void main()
  {
      cout&lt;&lt;k&lt;&lt;endl;
      getchar();
  }
  </code></pre>
  
  <p>Example 3: In this example I changed the order of definitions mentioned in example 1. When I compile this code I am getting errors. Why?</p>
  
  <pre><code>extern int k = 10;
  int k;   //error
  
  void main()
  {
      cout&lt;&lt;k&lt;&lt;endl;
      getchar();
  }
  </code></pre>