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, 22.06.2019 07:00
Our primary purpouse as electricians is to do wich of the following core concepts? a: install electrical components in a way they can be upgraded b: install electrical equiptment in a way that reduces heat c: install electrical systems in a safe manner d: only b and c
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
What makes myhexadecimalnumber a child of mynumber? which methods does myhexadecimalnumber inherit directly from the mynumber class? what can an instance of the mynumber class do? what can an instance of the myhexadecimalnumber class do? which methods are overridden? why are they overridden? how many examples of overloading are there? why was this done? where is the super keyword used? what is it doing? why isn’t the incoming value set immediately in the second myhexadecimalnumber constructor? how many examples can you find of an inherited method being called?
Answers: 1
question
Computers and Technology, 23.06.2019 18:40
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
question
Computers and Technology, 24.06.2019 18:20
Acommon algorithm for converting a decimal number to binary is to repeatedly divide the decimal number by 2 and save the remainder. this division is continued until the result is zero. then, each of the remainders that have been saved are used to construct the binary number.write a recursive java method that implements this algorithm.it will accept a value of int and return a string with the appropriate binary character representation of the decimal number.my code: public class lab16{public string converttobinary(int input){int a; if(input > 0){a = input % 2; return (converttobinary(input / 2) + "" +a); } return ""; } }
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
Social Studies, 26.08.2019 08:50
question
Chemistry, 26.08.2019 08:50
Questions on the website: 13722360