Answers for "check whethet a string is palindrome or not using recursion"

0

check whethet a string is palindrome or not using recursion

//C++ Code
#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(string str,int start,int end)
{
    if(start >= end) //base case
    return true;
    else{
        //if mismatch happens false will be returned else true
        return ((str[start] == str[end]) && isPalindrome(str,start+1,end-1));
    }
}
int main()
{
    int length = 5;
    string str = "ABCBA";
    bool ans = isPalindrome(str,0,length-1);
    if(ans == true)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}
Posted by: Guest on July-11-2021

Code answers related to "check whethet a string is palindrome or not using recursion"

Browse Popular Code Answers by Language