title: C++ Pointers and reference and functions
body: <p>I dont understand how this code works can you please explain it  to me. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int fun (int &amp;x, int &amp;y) {
      if (y&lt;=0)
          return x;
      x=x+2;
      cout&lt;&lt;x&lt;&lt;y&lt;&lt;endl;
      return x*y;
  }
  
  int main () {
      int x=5, y=-1;
      cout &lt;&lt;fun(x,y)&lt;&lt;endl;
      fun(y,x);
      fun(x,y);
      fun(y,x);
      cout &lt;&lt;fun(x,y)&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p>the correct answers are </p>
  
  <pre><code>5
  15
  71
  37
  93 
  27
  </code></pre>