palindrome is a string that reads the same both forward and backward.
C++
For example, the string "madam" is a palindrome.
Write a program that uses a recursive function to check whether a string is a palindrome.
Your program must contain a value-returning recursive function that returns true if the string is a palindrome and false otherwise. Do not use any global variables; use the appropriate parameters.
Solution.cpp
#include <iostream>//header file for input output
function
#include <cstring>//header file for string functions
using namespace std;//it tells the compiler to link std namespace
bool isPalindrome(char *inputString, int leftIndex, int
rightIndex);//function declaration
int main(){//main function
char Str[100];
cout<<"Enter a string for palindrome
check\n";
cin>> Str;//keyboard inputting
//calling
function
if(isPalindrome(Str, 0, strlen(Str) - 1)){
cout<<Str<<"
is a Palindrome \n"<< Str;
} else {
cout<<Str<<"
is not a Palindrome \n"<< Str;
}
return 0;
}
/*
* Function to check whether a string is palindrome or not
*/
bool isPalindrome(char *inputString, int leftIndex, int
rightIndex){
/* Input Validation */
if(NULL == inputString || leftIndex < 0
|| rightIndex < 0){
cout<<"Invalid Input";
return
false;
}
/* Recursion termination condition
*/
if(leftIndex >= rightIndex)
return true;
if(inputString[leftIndex] ==
inputString[rightIndex]){
return
isPalindrome(inputString, leftIndex + 1,rightIndex - 1);
}
return false;
}
output
madam
madam is a Palindrome
palindrome is a string that reads the same both forward and backward. C++ For example, the...
C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member functionbool isPalindrome( )that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main...
A palindrome is a word that is spelled the same forward and backward. For example, rotor and redder are palindromes, but motor is not. Write a recursive function that takes a word (string) and check if it is palindrome or not (The function should return True if the word is palindrome otherwise it should return False). USING PYTHON
C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member functionbool isPalindrome( )that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main...
A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. In this program, ask the user to input some text and print out whether or not that text is a palindrome. Create the Boolean method isPalindrome which determines if a String is a palindrome, which means it is the same forwards and backwards. It should return a boolean of whether or not it was a palindrome. Create the method reverse...
Palindrome Detector A palindrome is any word, phase, or sentences that reads the same forward and backward. Here are some well-know palindrome. Write a bool function that uses recursion to determine if a string arguments is a palindrome. The function should return true if the argument reads the same forward and backward. Demonstrate the function in a program
A Palindrome is a string that is spelled the same way forward and backward (example: radar). Write a Java program that asks the user to input a string and tests whether the string is a Palindrome or not. Display the message: "The string is a Palindrome" if it is, or "The string is NOT a Palindrome" if it is not. Assume that the user will enter a string without any spaces. The string can be any length. The String can...
Problem 1: (Palindromes) A palindrome is a string that's spelled the same way forward and backward. Some examples of palindromes are; radar, able was i ere i saw elba; and, if you ignore blanks, a man a plan a canal panama .Write a recursive function testPa1indrome that returns 1 if the string stored in the array is a palindrome and 0 otherwise. The function should ignore spaces and punctuation in the string. Please I need it in C program and...
Write a C Program that asks the user to input a string and then the user is prompted back whether the input string is a “Palindrome Word” or not. (A Palindrome Word reads the same backward or forward, eg. madam, racecar, etc.) Your program should contain a function that accepts the input string from the main function and returns a value indicating whether the input string is a Palindrome or not. Use Pointers to traverse the string.
A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it's a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.
In C++ Write a program that: Gets a string from cin Prints TRUE if the string is a palindrome, FALSE otherwise, all uppercase, followed by endl. Palindrome reads the same backward as forward, e.g., madam.