Small Factorial (What's wrong with this code?)

#include
using namespace std;
int factorial(int);
int main()
{
int t;
cin>>t;
int a[t],fact;
for(int i=0;i<t;i++)
{
cin>>a[i];
}
for(int i=0;i<t;i++)
{
fact=factorial(a[i]);
cout<<fact<<"\n";
}
return 0;
}

int factorial(int num)
{
if(num<=1)
return 1;
else
return num*factorial(num-1);
}