Hi runtime error SIGSEGV comming in PALIN
spoj.com/problems/PALIN/
My solution is here
include
long array[2000]={0};
long n=0;
int index=0;
void savepalindrome()
{
long lim=1000001;
long i=1;
for(i=1;i<=lim;i++){
if(checkpalindrome(i)==1){
array[index]=i;
index++;
}
}
}
int checkpalindrome(long i)
{
long reverse=0,temp;
int rem;
temp=i;
while(temp!=0){
rem=temp%10;
reverse=reverse*10+rem;
temp/=10;
}
if(reverse==i)
return 1;
else
return 0;
}
int main()
{
int t;
scanf("%d",&t);
savepalindrome();
while(t--){
scanf("%d",&n);
index=0;
while(array[index]<=n){
index++;
}
printf("%ld\n",array[index]);
}
}
working on ideone but not on spoj. Please help me in debugging this .
Could someone please point me to the error? OR the test case that would cause SIGSEGV?
Thanks,