Please tell me whats wrong in this code. Please give me one case where this fails so that I can correct it........
//LastDig.c
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int c[10]={1, 1, 4, 4, 2, 1, 1, 4, 4, 2};
long i, *ptr, lstBase, ex, base, power;
int n;
scanf("%d", &n);
ptr=(long*)malloc(2*n*sizeof(long));
for(i=0 ; i<2*n ; i++)
scanf("%ld", ptr+i);
for(i=0 ; i<2*n ; i+=2)
{
base=*(ptr+i);
power=*(ptr+i+1);
if(base==0 && power==0)
{
printf("1");
continue;
}
lstBase=base%10;
ex=power%c[lstBase];
if(lstBase==0)
printf("0");
else
{
if(ex==0)
printf("%ld\n", ((long)pow(lstBase, c[lstBase]))%10);
else
printf("%ld\n", ((long)pow(lstBase, ex))%10);
}
}
return 0;
}