+ 1

Palindrome Numbers challenge help c++

I'm having difficulty with how to reverse the numbers i don't think any of the previous lessons have gone through it, if there's any pointers of lesson or help would be appreciated.

12th Mar 2022, 8:06 PM
Angel Jimenez
Angel Jimenez - avatar
4 odpowiedzi
+ 5
You can also iterate through the number in reverse using a for loop, & decrement each iteration. Review lesson 16.1 of c++ for details. Then compare the original num against your new num
12th Mar 2022, 8:45 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Reverse number : n = 234 1) n%10 => returns 4 add to a variable rev 2) n=n/10 makes n = 23 => rev = 4, n = 23 Repeat these two steps in a loop until n>0 => rev = 43, n = 2 => rev = 432 , n = 0 finally, You get rev = 432. Just find how to add.. Finally if original n = 234 is not equal to rev( =432) so it's not polindrome... Angel Jimenez I hope you can try now. . . . Hope it helps..
12th Mar 2022, 8:26 PM
Jayakrishna 🇮🇳
+ 2
Here is how I've managed to do it using recursion in c++ https://code.sololearn.com/cWeS0D5HH6Tr/?ref=app
14th Mar 2022, 7:50 PM
Z3ro