Try running your code for input
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.
So that mean your code should be able to calculate maximum of 100 factorial and factorial of 100 is
which cannot be stored in integer or floating point datatypes in c or c++, So you have to use array to store the number.
Now how to do that ?
For this problem check this link: discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial
Hope you understood…!