Code gives wrong answer..cant figure out why.

For the question FCTRL2 ( Small Factorial), I wrote a code which gives correct answers for 100! or any other number i checked. I can’t figure out the reason for getting wrong answer upon submitting this solution. Please Help!!

My C++ code is as follows:

#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

int main()

{

    int t,num,l;
    int fact[200],carry[200];
    scanf("%d",&t);
    while(t--)
    {
        for(l=0;l<200;l++)
        {
            carry[l]=0;
            fact[l]=0;
        }
        cin>>num;
        int j=199;
        int temp=num;
        while(num)
        {
            fact[j]=num%10;
            num=num/10;
            j--;
        }
        int k;
        while(num>1)
        {
            k=199;
            while(k>=0)
            {
                int prod=num*fact[k];
                fact[k]=(prod+carry[k])%10;
                if(k!=0)
                    carry[k-1]=(prod+carry[k])/10;
                k--;
            }
            num--;
            for(l=0;l<200;l++)
            {   
                carry[l]=0;
            }
        }
        int flag=0;
        for(l=0;l<200;l++)
        {
            if(fact[l]!=0)
            {
                cout<<fact[l];
                flag=1;
            }
            else if (flag==0) 
            {
                continue;
            }
            else 
                cout<<fact[l];
        }
        cout<<"\n";
    }
    return 0;
}