title: Understanding namespace scope in c++
body: <p>When I run this below code snippet, the output is <strong>a is 6</strong>. But since I have used namespace n1, which also has variable by name "a", shouldn't the output be <strong>a is 5</strong>. Am I missing something ?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  namespace n1{
      int a = 5;
  }
  
  int main(void){
      int a = 6;
      using namespace n1;
      cout&lt;&lt;"a is "&lt;&lt;a&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p>But if I use fully qualified name in cout i.e cout&lt;&lt;"a is "&lt;&lt;<strong>n1::a</strong>; the output is as expected i.e. 5. What is the purpose of <strong>using namespace</strong> ?</p>