title: Why is the output not considering the function?
body: <pre><code>void func(int x) {
   x = 2;
  }
  
  int main()
  {
   int x = 3;
   func(x);
   cout &lt;&lt; "x = " &lt;&lt; x &lt;&lt; endl;
   return 0;
  }
  </code></pre>
  
  <p>I expect the out put to be 2. Why isn't this happening? A simple explanation since I only just started learning c++ please. Could you then explain why the following yields 5:</p>
  
  <pre><code>void func(int x)
  {
   x = 2;
  }
  
  
  void function(int *x)
  {
   *x = 5;
  }
  
  int main()
  {
   int x = 3;
   func(x);
   function(&amp;x);
   cout &lt;&lt; "x = "&lt;&lt; x &lt;&lt; endl;
   return 0;
  }
  </code></pre>