title: Recursion in C with Pre increment
body: <pre><code>int fact_rec(int n)
  {
      printf("%d\n",n);
      if(n==1) return n;
      else return fact_rec(--n)*n;
      //else return n*fact_rec(--n); gives same result
      //correct output comes for n*fact(n-1)
  }
  </code></pre>
  
  <p>In the above recursive implementation of the factorial function,
  <code>fact_rec(5)</code> returns 24. Whereas, if I use
  <code>n*fact_rec(n-1)</code>
  in place of
  <code>n*fact_rec(--n)</code>
  the output is correct : 120.
  Also, it doesn't matter whether I use
  <code>n*fact_rec(--n)</code>
  or
  <code>fact_rec(--n)*n</code>.
  Shouldn't it matter if I use
  <code>n*fact_rec(--n)</code>
  or
  <code>fact_rec(--n)*n</code>?</p>
  
  <p>And shouldn't the output have
  been 120 in all the cases?</p>