Question & Answer: (C++)Write a recursive function named isPalindrome that takes a C++ string as a parameter and returns a…..

(C++)Write a recursive function named isPalindrome that takes a C++ string as a parameter and returns a bool indicating whether that string is exactly the same forwards and backwards. For example, “racecar” would return true, but “Racecar” would return false.

Please write a new code to answer this question.

Expert Answer

 

#include <iostream>
#include <string.h>
using namespace std;
bool checkpallen(char[]);
bool findpallen(char[],int,int);
int main()
{
char names[]=”racecar”;
if(checkpallen(names))
cout<<“it is pallendrome string”<<endl;
else
cout<<“it not a pallendrome string”<<endl;
return 0;
}
bool checkpallen(char names[])
{
int len=strlen(names);
return findpallen(names,0,len-1);
}
bool findpallen(char names[],int i,int j)
{
if (names[i]!=names[j])
return false;
if (i<j+1)
return findpallen(names,i+1,j-1);
return true;
}

output screenshot when it is pallendrom string:

Question & Answer: (C++)Write a recursive function named isPalindrome that takes a C++ string as a parameter and returns a..... 1

output screenshot when it is not a pallendrome string:
Question & Answer: (C++)Write a recursive function named isPalindrome that takes a C++ string as a parameter and returns a..... 2/* the above is recursive program to find pallendrome string there is no check if you give empty string as input..so please give a string without empty string to get executed
*/

Still stressed from student homework?
Get quality assistance from academic writers!