3. A palindrome is a sentence that contains the same sequence of letters read-ing it either forwards or backwards. A classic example is "Able was I, ere I saw Elba." Write a recursive function that detects whether a string is a palindrome. The basic idea is to check that the first and last letters of the string are the same letter; if they are, then the entire string is a palindrome if everything between those letters is a palindrome. There are a couple of special cases to check for. If either the first or last character of the string is not a letter, you can check to see if the rest of the string is a palindrome with that character removed. Also, when you compare letters, make sure that you do it in a case-insensitive way. Use your function in a program that prompts a user for a phrase and then tells whether or not it is a palindrome. Here's another classic for testing: "A man, a plan, a canal, Panama!"

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
100%

3. A palindrome is a sentence that contains the same sequence of letters read-ing it either forwards or backwards. A classic example is "Able was I, ere

I saw Elba." Write a recursive function that detects whether a string is a palindrome. The basic idea is to check that the first and last letters of the
string are the same letter; if they are, then the entire string is a palindrome if everything between those letters is a palindrome.
There are a couple of special cases to check for. If either the first or last character of the string is not a letter, you can check to see if the rest
of the string is a palindrome with that character removed. Also, when you compare letters, make sure that you do it in a case-insensitive way.
Use your function in a program that prompts a user for a phrase and then tells whether or not it is a palindrome. Here's another classic for

testing: "A man, a plan, a canal, Panama!"

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning