Whats wrong in my code? - small factorials problem

#include

using namespace std;
int fact(int n)
{
if(n==1 || n==0)
return 1;
else if(n>1)
return n*fact(n-1);
else
return 0;

}
int main() {
int t;
int fac=0;
scanf("%d",&t);
while(t–>0)
{
int x;
scanf("%d",&x);
fac=fact(x);
printf("%d\n",fac);

}
return 0;

}

You can do the code in c++ and add boost multiprecision, because the output can be much greater,
boost multiprecision can handle the data* above long double.

2 Likes