Problem Code: FCTRL2

Problem :

You are asked to calculate factorials of some small positive integers.

Input :

An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.

Output :

For each integer n given at input, display a line with the value of n!

Sample 1:

Input :

4

1

2

5

3

Output :

1

2

120

6

#include<stdio.h>

int main()

{

int t,n,a[200],i,j,k,l,m;

scanf("%d",&t);

while(t–)

{

scanf("%d",&n);

m=1;

a[0]=1;

for(j=2;j<=n;j++)

{

l=0;

for(k=0;k<m;k++)

{

a[k]=a[k]*j+l;

l=a[k]/10;

a[k]=a[k]%10;

}

while(l)

{

a[k]=l%10;

k++;

m++;

l=l/10;

}

}

for(i=m-1;i>=0;i–)

printf("%d",a[i]);

printf("\n");

}

return 0;

}