Write a C++ Program to check whether a given number is a palindrome or not.

Example:

A number is Palindrome if its reverse is equal to itself. Examples: 101, 141, 808, 33, etc

palindrome number

Steps to Check Palindrome Number

  1. Input a number (num).
  2. Reverse the number (rev).
  3. Check if (rev == num).
  4. If YES, then its palindrome else not.

Let’s do the same in C++ program.

Check Palindrome number in C++

Output

Enter a number
1661
Palindrome number

Print all Palindrome number in the Interval in C++

For this, we will create a separate function that will return true or false depending on whether the passed number is a palindrome or not. We will use the same logic as used in the above program to check the palindrome number.

Finally, we will loop through each of the interval values, check it explicitly and will print it, if its a palindrome.

Output

Enter a lower interval value
1
Enter a upper interval value
100
1 2 3 4 5 6 7 8 9 11 22 33 44 55 66 77 88 99

If you have any doubts or suggestion then comment below.

Leave a Reply

Close Menu