Please tell me the problem

,

#include <stdio.h>
int fact(int n);
int main(void) {
int t;
scanf("%d",&t);
while(t!=0)
{
int n;
scanf("%d",&n);
printf("%d\n",fact(n));
tโ€“;
}
return 0;
}
int fact(int n)
{
int result;
if(n==0||n==1)
{
return 1;
}
else
{
result=n*fact(n-1);
return result;
}
}

You cannot store factorial of numbers above 16 in integer so it fails for larger input .
You can check its solution here

2 Likes

Sir I have not studied C++ or any other language other than C . Kindly provide solution in C language if possible.
Thank you

1 Like