getting wrong answer in small factorial

#include<stdio.h>
int main(){
int a,i,j;
double z;
scanf("%d",&a);
for(i=0;i<a;i++){
scanf("d",&j); for(z=1;j>0;j--) z=z*j; printf(".0lf\n",z);
}
return 0;
}

The integer limit is 2147483647. The value of 100! is far greater than this so you are getting a wrong answer. Try to come up with a different approach.

Have a look at this tutorial

z is double and 100! is stored in z