title: Passing by Pointers vs Passing by reference
body: <p>I have understood the fact that a calling a function by reference can be done in two ways either passing the variable by reference or passing the variable by pointers. 
  But now I am stuck at the o/p difference of it </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  void test(int *a)
  {
  
      cout&lt;&lt;&amp;a&lt;&lt;"  ";
  }
  int main()
  {
     int a[4]={5,3,8,2};
     for(int i=0;i&lt;4;++i)
     {
          test(&amp;a[i]);    
     }
      return 0;
  }
  </code></pre>
  
  <p>This gives me the same address location but shouldn't it be different as we are passing &amp;a[i]--> the address of ith element every time it is called which is received by the pointer a but I get the same address every time which is the starting address of the array 
  while if I modify the function call somewhat I get the expected o/p 
  which is from the below code</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  void test(int &amp;a)
  {
  
      cout&lt;&lt;&amp;a&lt;&lt;"  ";
  }
  int main()
  {
     int a[4]={5,3,8,2};
     for(int i=0;i&lt;4;++i)
     {
          test(a[i]);    
     }
      return 0;
  }
  </code></pre>