+ 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

28th Oct 2022, 11:31 PM
Anthony Kwesi Saah
Anthony Kwesi Saah - avatar
4 Réponses
+ 3
Thanks very much. It worked
29th Oct 2022, 12:33 AM
Anthony Kwesi Saah
Anthony Kwesi Saah - avatar
+ 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
29th Oct 2022, 12:28 AM
SoloProg
SoloProg - avatar
+ 1
Be aware of reverse number you are forming. Which can be overflowed. Try to take cast into long long to play safe....
30th Oct 2022, 6:57 AM
saurabh
saurabh - avatar