coding question on factorial

this is my code to calculate factorial of n<=100 .
It is showing correct answer till 4 but then at 5 it shows 20 in place of 120 and from 6 onwards it shows 0.
please help in correcting my code.

here`s my code :

#include

using namespace std;

int main(){

int T,n,a[200],len=-1;

cin>>T;

while(T--){

    cin>>n;

    a[0]={1};

    if (n==1)

        cout<<"1";

    for(int i=2;i<=n;i++){

      int temp=0;

      len=1;

      for(int l=0;l<=199;l++){

          int x=a[l]*i+temp;

          a[l]=x%10;

          temp=x/10;

          if(temp==0)

              break;

          len++;

      }

    }

    for(int k=len-1;k>=0;k--)

        cout<<a[k];

    cout<<""<<endl;

}

return 0;

}