title: Here's a program to find the factorial of a number. Why am I getting 0 as the answer? Which datatype should I use instead?
body: <p>I'm relatively new to C. I made this program to find the factorial of any number. Upon executing the program, when I provide 33 as the input - I get 2147483648 as the answer. If I provide 34, I get 0 as the answer.</p>
  
  <p>Getting to my question - Why did I get 0 as the answer? The datatype I've used has a range of 0-4294967295. Am I getting 0 cause this is outside the range of unsigned int? Which datatype should I use if I want to get a large number as the output? </p>
  
  <p>Compiler used - GCC 8.2.1 </p>
  
  <p>Here's the code - </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  int fact(unsigned int n)
  {
          int result;
          if(n==0 || n==1)
                  result=1;
          else
                  result=n*fact(n-1);
          return result;
  }
  int main()
  {
          unsigned int n,ans;
          printf("Enter n:");
          scanf("%u",&amp;n);
          ans=fact(n);
          printf("Factorial of %u:%u",n,ans);
  }
  </code></pre>