I used single digit integers but my code is returning wrong answer for 67!.Please tell me where exactly my code went wrong?

#include<stdio.h>

void B(int k);
int a[171];
int sum,i;
int main()
{     int k,n,o,l,t,j;
      scanf("%d",&t);
      for(j=1;j<=t;j++)     
            {scanf("%d",&n);
             for(i=2;i<=170;i++)
                  a[i]=0;
                 
                  a[0]=0;
                  a[1]=1;
                  k=1; 
             for(i=1;i<=n;i++)
                  {sum=0;
                   a[k]=a[k]*i+sum;              
                   B(k);  
                  } 
     
              
              for(o=170;o>=1;o--)
                  {if(a[o]>0)
                       {
                             l=o;
                              break;
                       }                 
                  } 
      
      for(i=l;i>=1;i--)
      printf("%d",a[i]);
      printf("\n");
      }
      
      return 0;
      }
void B(int k)
{int m;
      for(m=1;m<=170;m++)               
     {
     sum=a[k]/10;            
     a[k]=a[k]%10;  
     k++;
     
     
     a[k]=a[k]*i+sum;
     
     }
     
}

I think it is correct as c++ code.

Try submitting it as c++,
It will get AC.

1 Like

yeah …that solves it.Thank u.

//