Its easier to turn the number into a char array....
Code:
#include <iostream>
#include <cstdio>
using std::cout;
using std::endl;
bool isPal(int y){
int a,b,c;
char buff[20];
b = sprintf(buff,"%d",y);//get char array
c = b / 2;//times to loop. If odd, then carry is lost
for(a = 0,--b;c;a++,b--,c--){
if(buff[a] == buff[b])
continue;//Same.....good, go again
else{//1 difference, so no pallindrome
cout << buff << " is not a palindrome" << endl;
return false;
}
}
cout << buff << " is a palindrome" << endl;
return true;
}
int main()
{
isPal(2552);//Yes
isPal(2556);//No
isPal(78987);//Yes
isPal(56874);//No
return 0;
}