+ 1
Logic of palindrome no.
Please tell me how I implement the code to check the no. Is palindrome or not in java or c++
2 Antworten
+ 2
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...
Think for number 121:
Reversing it, you will get 121 same so it's a polindrome.
Hope it helps..
+ 2
hope this link helps you In c++
https://code.sololearn.com/cIn5oho2RLrY