Small factorial: help

i have run this code in my compiler it work fine till its upper limit as per given in the question. But codechef gives it wrong every time. please any body help. the link to the question given below

include<stdio.h>
int fact(int p[],int q,int t){

t--;
int i,temp=0,x;

for(i=0;i<q;i++){

x=p[i]*t+temp;

p[i]=x%10;

temp=x/10;

}

while(temp>0){

q++;

p[q-1]=temp%10;

temp/=10;

}

if(t>1){

fact(p,q,t);

}
else{

printf("\n");
for(i=q-1;i>=0;i--){

printf("%d",p[i]);
}
}

}

int count(int x){

int p[200],t=x,q=0,i,j;

if(x==1){

printf("%d",x);

}

else{

for(i=0;t>0;i++){

p[i]=t%10;

t/=10;

q++;

}

fact(p,q,x);
} }

int main(){

int t,i,j,a[100];

scanf("%d",&t);

for(i=0;i<t;i++){

scanf("%d",&a[i]);

}

for(i=0;i<t;i++){

count(a[i]);


}
}

You have not taken proper care of New Line. I want you to track it down yourself. As a help check your program output for:

3
6
1
1
1 Like

thanks a lot vaibhavatul47