subject

Complete the program below. 1) First the user is asked to enter a word. Then the program determines whether the word is a palindrome. A palindrome is a word that is spelled the same whether begin to end or vice-versa. For example, racecar is a palindrome, whereas yellow is not (wolley backwards). /* Output Enter a word: racecar racecar is a palindrome. /* Output Enter a word: yellow yellow is not a palindrome.
2) The word is read using getline().
3) Then a for loop is used to push the word into a STL list. - With each iteration, one character is pushed into the list. - The for loop stops when the null character '\0' is encountered. Now the list holds the word. To determine whether a word is a palindrome, the first character in the list must equal the last character. Then the second letter in the list must equal the next-to-the-last character... and so on.
4) So use a loop and iterate through the list in both directions using two iterators. - Use a loop to check the first character to the last, use both iterator it, and reverse_iterator rit. it rit word. begin() word. begin() • In the first iteration, check the first character to the last character. o If they are not the same, break out of the loop. . If they are the same, progress the the second character from the front to the second character from the end. • To move the iterator it to the next character, use it++. o Likewise, to move the reverse_iterator rit to the next character (in reverse order), use rit++.
5) Use this code and then finish the program. #include #include #include using namespace std; int main() list characters; string word; Notice that we can use the subscript operator ( 1 with a string, (not just with c_strings). cout << "Enter a word: "; getline (cin, word); for (int i = 0; word[i] != '\0'; i++) characters. push_back (word[i]); // //
6) Now the list holds the word, with each node in the list holding one character. // Include code below to determine whether the word is a palindrome.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
If joey was single and his taxable income was $9,500, how much would he pay in taxes each year?
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
Answers: 1
question
Computers and Technology, 24.06.2019 23:30
What is the opening page of a website called? a. web page b. landing page c. homepage d. opening page
Answers: 1
question
Computers and Technology, 25.06.2019 05:00
How many meatballs required for a larty of 25 adults and 6 children
Answers: 1
You know the right answer?
Complete the program below. 1) First the user is asked to enter a word. Then the program determines...
Questions
question
Mathematics, 10.02.2020 02:48
question
Arts, 10.02.2020 02:49
question
Biology, 10.02.2020 02:49
question
Mathematics, 10.02.2020 02:49
Questions on the website: 13722360