+ 3
C++ Palindrome Numbers Solution?
I'm having trouble solving the C++ palindrome numbers project in the course. Could anyone help out. My code is just not working
4 Answers
+ 3
Thanks very much. It worked
+ 1
// Hope this helps
bool isPalindrome(int x) {
int r, sum=0, temp;
temp=x;
while(x>0) {
r=x%10;
sum=(sum*10)+r;
x=x/10;
}
return(temp==sum);
}
https://www.sololearn.com/compiler-playground/cIn5oho2RLrY
+ 1
Be aware of reverse number you are forming.
Which can be overflowed.
Try to take cast into long long to play safe....