Small Factorial problem

Sir, this is my code for small factorial problem but I am not able to find out my mistake as it is giving my perfect output but codechef is not accepting it…?

#include<stdio.h>
main()
{
int t,fact=1,i,n;
scanf("%d",&t);
int a[t];
for(i=0;i<t;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<t;i++)
{
fact=1;
n=a[i];
while(n!=1)
{
fact=fact*n;
n=n-1;
}
printf("\n%d",fact);
}
}

Hi @akhil_825 ! That’s because of the integer overflow ! It gives u correct answer for n<=20/n<=21 (approx) ! Try for n=100,it gives u some garbage value !

The factorial value exceeds the ‘int’ range. ‘int’ data type can only hold 32 bits but factorial of 100 is about 10^158.