runtime error

#include <stdio.h>
#include<math.h>
#include<string.h>

int getLength(long int a)
{
	int length=0;
	while(a>0)
	{
		a=a/10;
		length++;
	}
	return length;
}



int main()
{
    int ar[20][2];
    int t,l,i=0,d;long int m;int ans;
   printf("enter number of test cases"); 
   scanf("%d",&t);
   while(i<t)
   {
       printf("enter n and k:");
       scanf("%d",&ar[i][0]);
       scanf("%d",&ar[i][1]);
       i++;
       printf("\n");
   }
   i=0;
   while(i<t)
   {    double b=ar[i][0];
        double k=ar[i][1];
        m=(long int)pow(b,b);
        l=getLength(m);
        d=(int)pow(10,l-k);
        ans=m/d;
        printf("%d ",ans);
        d=(int)pow(10,k);
        ans=m%d;
        printf("%d",ans);
	i++;
	printf("\n");
   }
   
   return 0;
}

Which problem are you trying to solve?

If it is a codechef problem you don’t have to ask for the user to “enter number of test cases”. Just print what the problem specifies you to print. This might not be the reason for runtime error but your code will definitely not be accepted if you keep those printf statements that have nothing to do with the problem. Codechef problems are not evaluated by humans. You should at least add a description of what exercise you are trying to solve. That will help users that are willing to help identify the problem.

1 Like

@junior94 i think he is solving A4!!!

//