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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, Samsonb
Working on this program in python 3.7: a year in the modern gregorian calendar consists of 365 days. in reality, the earth takes longer to rotate around the sun. to account for the difference in time, every 4 years, a leap year takes place. a leap year is when a year has 366 days: an extra day, february 29th. the requirements for a given year to be a leap year are: 1) the year must be divisible by 42) if the year is a century year (1700, 1800, the year must be evenly divisible by 400some example leap years are 1600, 1712, and 2016.write a program that takes in a year and determines whether that year is a leap year. ex: if the input is 1712, the output is: 1712 is a leap year. ex: if the input is 1913, the output is: 1913 is not a leap year. your program must define and call the function isleapyear(useryear). the function should return true if the input year is a leap year and false otherwise.
Answers: 1
image
Computers and Technology, 22.06.2019 22:30, raiapowell
I'll mark brainliest if answered right! with which feature or menu option of a word processing program can you make an image like this? you can get this image using the option of a word processing program.
Answers: 1
image
Computers and Technology, 22.06.2019 23:00, cchotshot
Is an attack that relies on guessing the isns of tcp packets
Answers: 2
image
Computers and Technology, 22.06.2019 23:30, elizabethburkha
Which text format is this, "the text is transcribed exactly as it sounds and includes all the utterances of the speakers. "?
Answers: 2
You know the right answer?
Complete the program below. 1) First the user is asked to enter a word. Then the program determines...

Questions in other subjects: