problem submission error?

why my answer are not being accepted ,i am new here .i am confused what is test case and how to use it in code.
even super basic program like factorial are not being accepted.(Problem Code: FCTRL2) . help;
i wrote following code
#include<stdio.h>
int main()
{
int t ,n ,i=0 ,fac=1 ;
scanf("%d",&t);
while(t>0)
{
{
scanf("%d",&n);
}
if(n>0)
{for(i=1;i<=n;i++)
{
fac=fac*i;
}
printf("%d\n",fac);
}
if(n==0)
{printf("%d\n",1);}
t–;
fac=1;
}
return 0;
}

//