Question
Write a C++ program that takes a word as input from the user. Enter a word: noon (user types noon and enter) The program then
Write a C++ program that takes a word as input from the user. Enter a word: noon (user types "noon" and enter) The program then prints out a message "It is a palindrome" or "The word has the property that is is spelled the same forward and backward. If the word does not have the property, print something like "It does not have the property.
//Write a program to input a word from the console. If the word is spelled the same forward as backward,
//then print out a message that is is a palindrome.
// Reverse Character
#include
int main() {
// 1. Get first character. Hint use substr()
// 2. Remove first character. Use erase()
// 3. Add first character to the end. Use string concatenation.
// 4. Now reverse the spelling of the word and save it. Use a for loop, erase(), and length()
// 5. Compare the original word with the reversed word. If they match, print out they have the property // Use string comparison == with an if statement
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started