Starting from:
$30

$24

HW 7 Problem Solution

A *palindrome* is a word, number, phrase, or other sequence of characters which reads the same backward as forward.

- Example: 123321, 4321234




Write a program that determines if an integer number is a [palindrome](https://en.wikipedia.org/wiki/Palindromic_number).







- Write a function called `reverse` that takes a positive integer and returns the reverse of that number.

- For example: If the input for the function is `1234`, it should

return `4321` as an integer, not string.







- Write a function called `isPalindrome` that tests if the number is a

palindrome, then returns true, else returns false.

- Hint: Use the `reverse` function. If a number and its reverse are the same, then it is a palindrome.







Use below test driver to check correctness of your program.




---




Test Driver




```c++

#include <iostream

#include <iomanip

using namespace std;




unsigned int reverse(unsigned int);

bool isPalindrome(unsigned int);




int main()

{

cout << boolalpha << "123321 is a palindrome: " << isPalindrome(123321) << endl;

cout << "4321234 is a palindrome: " << isPalindrome(4321234) << endl;

cout << "1003003001 is a palindrome: " << isPalindrome(1003003001) << endl;

cout << "100300300 is a palindrome: " << isPalindrome(100300300) << endl;

return 0;

}

```

More products