Why is this code not working?output is not printed : When i compiled in devc++ compiler,output is not printed.
Is there any logical error?
This program should accept a number from the user,print the lowest palindrome greater than the given number.
 It is a problem from  SPOJ PALIN

#include <iostream>
using namespace std;

int main()
 {
	
	int t;
	
	cin>>t;
	cout<<endl;
	
	while(t--)
	{long long int i;
	long long int k;
	int flag;
	long long int n;
	int a[10000000];
		cin>>n;
		n++;
		start:
		i=0;
		while(n!=0)
		{
			a[i]=n%10;
		i++;
		n=n/10;}
		i--;
		k=i;
		for(int j=0;j<=k;j++)
	{	
		if(a[i]!=a[j])
		{flag=0;break;}
		else
		i--;
	}
	if(flag==1)
	cout<<n<<endl;
	else
	{n++;goto start;}
	
	}
		return 0;
}