isNumPalindrome(int)

I was having a little trouble with this programming assignment for my computer programming class. We use the C++ program and was asked to do the following assignment: - Write a function bool isNumPalindrome(int)
to determine whether an integer is a palindrome. For examples: 67876 is palindrome, 234 is not.
- Write the main function to provide a menu driven interface, which let users to input integers to test if it is a palindrome.

I have been working on it all week and it is due tomorrow night! Any help is appreciated! Thanks in advance!
it is same like character palindrome... if you know how to write a palindrome code it is ok.. i can give you the code but you will never learn like that.. :-)
closed account (1yR4jE8b)
If you already have a palindrome function that works for strings, you can use an std::stringstream, put your number into it, get a string version by using .str() from that stream then pass it into the palindrome function for strings.

There's ways to do this with modulus and what-not, but just converting it to a string is much easier.
it would easy to write a function to reverse the number and then numbrr1 - number 2

where the function like that

int rev( int numa
{
if(numa<10)
return numa;
return 10*(numa%10+rev(numa/10));
}
Last edited on
Topic archived. No new replies allowed.