Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

runtime error

$
0
0
#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;
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>