title: C++ Recursive functions
body: <p>I'm learning C++ and I have trouble with getting recursion working when a function is called by itself. </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int countdown(int y) {
      if (y==1) {
          return 1 &amp;&amp; cout &lt;&lt; y &lt;&lt; endl;
      }
      else {
          return countdown(y-1);
      }
  }
  
  int main () {
      cout &lt;&lt; "Countdown from ten: " &lt;&lt; endl;
      cout &lt;&lt; countdown(10) &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Of course there are other ways to achieve this, but really I created this example to verify my own understanding of how functions are called recursively.</p>
  
  <p>In the example I added <code>&amp;&amp; cout &lt;&lt; y</code> to verify if <code>y</code> is being passed to the function as <code>1</code>, which always appears to be the case irrespective that I call the function as <code>countdown(10)</code>.</p>
  
  <p>Could someone tell me if I'm missing something obvious here please?</p>