title: Calculating factorial of large numbers in C
body: <p>In my C code, I want to calculate the factorial for numbers in the range 1 to 100. For small numbers, the function works, but for bigger numbers (for example 100!) it returns incorrect result. Is there any way to handle factorial of large numbers in C?</p>
  
  <p>The compiler I'm using is gcc v4.3.3.
  My code is as follows:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  double print_solution(int);
  
  int main(void)
  {
          int no_of_inputs, n;
          int ctr = 1;
  
          scanf("%d",&amp;no_of_inputs); //Read no of inputs
  
          do
          {
                  scanf("%d",&amp;n); //Read the input
                  printf("%.0f\n", print_solution(n));
                  ctr++;  
          } while(ctr &lt;= no_of_inputs);
  
          return 0;       
  }
  
  double print_solution(int n)
  {
          if(n == 0 || n == 1)
                  return 1;
          else
                  return n*print_solution(n-1);
  }
  </code></pre>