#include <iostream>
#include <string>
#include <algorithm>
bool isPalindrome(const std::string& str) {
std::string temp = str;
std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
std::string reversed = temp;
std::reverse(reversed.begin(), reversed.end());
return temp == reversed;
}
int main() {
std::string input;
std::cout << "Enter a string: ";
std::getline(std::cin, input);
if (isPalindrome(input)) {
std::cout << input << " is a palindrome." << std::endl;
} else {
std::cout << input << " is not a palindrome." << std::endl;
}
return 0;
}
isPalindrome() function checks if a given string is a palindrome or not. It creates a copy of the input string, converts it to lowercase using std::transform, creates a reversed copy of the lowercase string using std::reverse, and finally checks if the original lowercase string and the reversed lowercase string are equal.main() function, it prompts the user to enter a string, stores it in the input variable, and then calls isPalindrome() to determine if the input string is a palindrome or not. Finally, it outputs the result to the console.