Problem - If the reversed integer is equal to the integer entered by user then, that number is a palindrome if not that number is not a palindrome. We need to check if a string passed is a palindrome.
Example -
“madam” is a palindromic string because it reads the same forwards and backward. Other palindromic strings are “anna,” “civic,” “level,”.
Using reverse() and strlen() this problem is simplified in the video.
Approach used is -
- First take a string as input.
- Compare the first and the last character of the string. If they are equal, then compare the second and the second last character of the string, and so on, until we get to the middle of the string.
- If the characters do not match at any iteration, then the string is not a palindrome.