title: Why do pass by pointer function works if we simply pass the variables please guide
body: <p>I was practising with C++ Pointers and trying different things and came to know about this thing:</p>
  <p>The Variables number 1 and number 2 does not has the address they stores integer but the function swap wants two pointers But this works...</p>
  <p>But it should only give the answer with the &amp; or pointers. Why This happens and if this is valid then what we call it?</p>
  <p>Kindly guide Me!!!!</p>
  <p>Complete Code is:</p>
  <pre><code>    #include&lt;iostream&gt;
  using namespace std;
  
  void swap (int *, int *);
  
  
  int main()
  {
      int number_1 =0;
      int number_2=0;
      
      cout&lt;&lt;&quot;Please Enter The First Number : &quot;;
      cin&gt;&gt;number_1;
      
      cout&lt;&lt;&quot;Please Enter The Second Number : &quot;;
      cin&gt;&gt;number_2;
      
      
      int *ptr_number_1=&amp;number_1;
      int *ptr_number_2=&amp;number_2;
      
  
      
      cout&lt;&lt;&quot;Before The Function Call Numbers Are : &quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;Number 1 Contains : &quot; &lt;&lt; number_1&lt;&lt;endl;
      cout&lt;&lt;&quot;Number 2 Contains : &quot; &lt;&lt; number_2&lt;&lt;endl;
      
      cout&lt;&lt;&quot;==================================&quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;Calling the Function with the direct variables : &quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;After The Function Call Numbers Are : &quot;&lt;&lt;endl;
      swap (number_1,number_2);
      cout&lt;&lt;&quot;Number 1 Contains : &quot; &lt;&lt; number_1&lt;&lt;endl;
      cout&lt;&lt;&quot;Number 2 Contains : &quot; &lt;&lt; number_2&lt;&lt;endl;
      cout&lt;&lt;endl;
      cout&lt;&lt;&quot;==================================&quot;&lt;&lt;endl;
      
      cout&lt;&lt;&quot;==================================&quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;Calling the Function with the Reference Operator : &quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;After The Function Call Numbers Are : &quot;&lt;&lt;endl;
      swap (&amp;number_1,&amp;number_2);
      cout&lt;&lt;&quot;Number 1 Contains : &quot; &lt;&lt; number_1&lt;&lt;endl;
      cout&lt;&lt;&quot;Number 2 Contains : &quot; &lt;&lt; number_2&lt;&lt;endl;
       cout&lt;&lt;endl;
      cout&lt;&lt;&quot;==================================&quot;&lt;&lt;endl;
      
      cout&lt;&lt;&quot;==================================&quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;Calling the Function with the Pointers  : &quot;&lt;&lt;endl;
      cout&lt;&lt;&quot;After The Function Call Numbers Are : &quot;&lt;&lt;endl;
      swap (ptr_number_1,ptr_number_2);
      cout&lt;&lt;&quot;Number 1 Contains : &quot; &lt;&lt; number_1&lt;&lt;endl;
      cout&lt;&lt;&quot;Number 2 Contains : &quot; &lt;&lt; number_2&lt;&lt;endl;
       cout&lt;&lt;endl;
      cout&lt;&lt;&quot;==================================&quot;&lt;&lt;endl;
      
      
      
  
      cout&lt;&lt;endl;
      return 0;
  }
  
  void swap (int *number_1, int *number_2){
      
      int temp_number_variable =0;
      temp_number_variable = *number_2;
      *number_2 = *number_1;
      *number_1 = temp_number_variable;
      
  }
  </code></pre>