Question: Write a program/algorithm or pseudo-code in C++ to check whether a string is a palindrome or not. To check if a string is a palindrome
Write a program/algorithm or pseudo-code in C++ to check whether a string is a palindrome or not. To check if a string is a palindrome or not, a string needs to be compared with the reverse of itself. Consider a palindrome string: lol, index: 012 value: 101 To compare it with the reverse of itself, the following logic is used: Oth character in the char array, string1 is the same as 2nd character in the same string. . ith character is the same as 'length-i-1'th character. If anyone of the above condition fails, the flag is set to true(1), which implies that the string is not a palindrome. By default, the value of the flag is false(0). Hence, if all the conditions are satisfied, the string is a palindrome
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
