title: c function not returning result
body: <p>I've very recently started to learn C, so I realize my question is very basic, but any help would be very much appreciated.</p>
  
  <p>I'm trying to get the function fact to return the res value to main, but when I print out the result in main I just get 0. By inserting some print statements I can see that res is calculating correctly in the fact routine but the result is not returning correctly to main.</p>
  
  <p>I'm sure I'm missing something very basic here.</p>
  
  <p>Thanks</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  unsigned long fact (int n){
      unsigned long res = 1;
  
      while ( n &gt;= 0 )
      {
          res *= n;
          n--;
      }
  
      return res;
  }
  
  int main (void){
      int n;
      unsigned long res;
  
      printf("Insert number:\n");
      scanf("%d", &amp;n );
  
      res = fact (n);
  
      printf("The factorial number is %lu", res);
  
      return 0;
  }
  </code></pre>