Problem: Write a C++ program to check whether a given string is a palindrome or not.

Example:

A palindrome string is that string which in reverse is equal to the original string.

Palindrome string

To check palindrome string in C++:

  1. Input the string.
  2. Reverse the string.
  3. Check whether the reverse of the string is equal to the input string.
  4. If yes, then the string is a palindrome, or else it is not.

Here is the implementation of the steps in C++:

Output:

Enter a string: mom
Palindrome


Strings such as Mom (first letter as upper case) do not match up with its reverse despite being a palindrome. So in the program, we lower the case of the characters before assigning them to the rev variable.

In this programming example, we learned to check a palindrome string in C++.

Leave a Reply

15 − 12 =