title: Why does this program swap the values?
body: <p>I have the following code:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  using namespace std;
  #include &lt;conio.h&gt;
  #include &lt;cstring&gt;
  #include &lt;iomanip&gt;
  
  void swap(long a, long b)
  {
      long temp;
  
      temp=a;
      a=b;
      b=temp;
  }
  int _tmain(int argc, _TCHAR* argv[])
  {
      int x = 5, y = 3;
      cout &lt;&lt; x ;
      cout &lt;&lt; y &lt;&lt; endl;
  
      swap(x, y);
  
      cout &lt;&lt; x ;
      cout &lt;&lt; y &lt;&lt; endl;
  
      getch();
      return 0;
  }
  </code></pre>
  
  <p>The program gives the output:</p>
  
  <pre><code>5 3
  
  3 5
  </code></pre>
  
  <p>The program actually swaps the values!  Why is that? The parameters of the <code>swap()</code> are not pointers or references.</p>
  
  <p>(I am using VS 2005)</p>