shows runtime error,but works in dev for small factorial.

int fact(int n)
return 1;
return (fact(n-1)*n);
int f,i,t,a[20];
return 0;

please paste your code in proper blocks or use

Read the constraints carefully. 1<=t<=100 but you are declaring array size of “a[ ]” as 20. So ArrayIndexOutOfBounds runtime error for t>=20 occurs.

Also your approach for this problem is not correct, 1<=n<=100 so you need to be able to produce the value of upto 100! ( factorial of 100 ) which is a very large number ( won’t fit in long long int).

You are declaring a[] of size 20 for storing the value of every test case, what if the number of test cases is greater than 20(t<=100 as given in the problem constraints). This is giving you the run time error. Also, do you think your recursive implementaion will give you the correct answer for n=100 and kind large values? Just check your code and test it once. You’ll probably get an overflow because the factorial of such large numbers will not fit in any datatype.

You’ll have to go through this post for learning something new.