Palindrome String

#include <iostream>
#include <string>
using namespace std;

// Function to check if a string is a palindrome
bool isPalindrome(const string& str) {
    int left = 0;
    int right = str.length() - 1;

    // Continue checking characters from both ends until they meet
    while (left < right) {
        if (str[left] != str[right]) {
            return false; // If characters do not match, it's not a palindrome
        }
        left++;
        right--;
    }

    return true; // If the loop completes, the string is a palindrome
}

int main() {
    string input;

    // Get user input
    cout << "Enter a string: ";
    getline(cin, input);

    // Check if the input string is a palindrome
    if (isPalindrome(input)) {
        cout << "The string is a palindrome." << endl;
    } else {
        cout << "The string is not a palindrome." << endl;
    }

    return 0;
}