help with next palindrome , c++ .

for - .
my c++ code works fine on Xcode but code chef shows wrong answer .


using namespace std;

int reverse_number(int n)


 int r=0, a;







 return r;


int main()

{int  n ;

cin >> n;

while ( n--)

{ int b;

cin >> b;

for ( int i = b ; i < 100000 ; ++i)


 if (reverse_number(i) == i )

 { cout <<i;



 return 0;


Read the Q carefully!! It says that-

For a given positive integer K of not more than **1000000 digits**, 

If its 1000000 digits, you will have to take input as a STRING and check for palindrome, you cannot store it as an integer in int or long as these many digits are too large, it will cause overflow.

For reference, long long int stores only 18-19 digits.