A palindrome is a word that is spelled the same forward and backward, such as \"
ID: 3642297 • Letter: A
Question
A palindrome is a word that is spelled the same forward and backward, such as "radar" or "madam." Your program should ask the user to enter a word, and then tell the user whether or not that word is a palindrome. Your program doesn't need to determine whether or not the word is in the English language. But you can assume that the word is made up of lower-case letters only, and that it is no more than 30 letters long. So for example your program would determine that the word "abcdefghijjihgfedcba" is a palindrome.Hints and Rules:
You must use a c-string (null-terminated character array) to store the word the user enters (as we have been doing all semester). You are not allowed to use the class "string" in this program.
To determine how many characters are in a c-string, use the strlen function. You will need to "#include <cstring>", and then if you have a c-string called "str" you can store its length in the variable "len" you would write: "len = strlen(str);"
You must have one function besides main(), that accepts the c-string as a parameter and returns a boolean, which represents whether a word is a palindrome or not.
Program input: radar
Program Output:
Please enter a word:
"radar" is a palindrome.
Program Input: madam
Program Output:
Please enter a word:
"madam" is a palindrome.
Program Input: abcdefghijjihgfedcba
Program Output:
Please enter a word:
"abcdefghijjihgfedcba" is a palindrome.
Program Input: dogeeseseegood
Program Output:
Please enter a word:
"dogeeseseegood" is not a palindrome.
Program input: tieit
Program Output:
Please enter a word:
"tieit" is a palindrome.
Program Input: didhannahsayashannahdid
Program Output:
Please enter a word:
"didhannahsayashannahdid" is a palindrome.
Program Input: nipaxpin
Program Output:
Please enter a word:
"nipaxpin" is not a palindrome.
Program Input: aaaaacbbbb
Program Output:
Please enter a word:
"aaaaacbbbb" is not a palindrome.
Explanation / Answer
This should get you started. All you have to do is convert to cstrings *********************************************** #include #include using namespace std; int main() { string input; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.