#include <iostream>
#include <string>

bool isPalindrome(const std::string& str, int start, int end) {
    // Base case: If start >= end, it means we've checked all characters
    if (start >= end) {
        return true;
    }
    // If characters at current indices don't match, it's not a palindrome
    if (str[start] != str[end]) {
        return false;
    }
    // Move towards the center
    return isPalindrome(str, start + 1, end - 1);
}

int main() {
    std::string str = "madam";
    int sz = str.size();
    if (isPalindrome(str, 0, sz - 1)) {
        std::cout << str << " is a palindrome." << std::endl;
    } else {
        std::cout << str << " is not a palindrome." << std::endl;
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: