C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 21, Problem 21.16E
Program Plan Intro
Working with Palindromes
Program Plan:
- Include the required header files.
- Define the “main” function.
- Accept a string sentence in line string variable.
- Create an integer variable counter and assign it to 0.
- Create a
vector of string to save tokens. - Create an object of stringstream class.
- Use a loop to tokenizing with respect to space ' '.
- Use a loop to iterate through vector tokens.
- Create a string object str.
- Transform all the tokens into lower case.
- Assign the value of current token to str.
- Reverse the value of str.
- Compare the reversed str value with current token to check whether it is a palindrome or not.
- If it is a palindrome display the current token.
- Increment the counter variable.
- Display the total number of palindromes in the sentence.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Draw the expression trees that represent the following expressions
Program to add
What is the likelihood of an error in the REpitition code, also known as the Huffman code?
Chapter 21 Solutions
C++ How to Program (10th Edition)
Ch. 21 - Prob. 21.4ECh. 21 - Prob. 21.5ECh. 21 - (Find Code Error) Find any errors in the following...Ch. 21 - (Simple Encryption) Some information on the...Ch. 21 - Prob. 21.8ECh. 21 - Prob. 21.9ECh. 21 - (String Concatenation) Write a program that...Ch. 21 - (Hangman Game) Write a program that plays the game...Ch. 21 - (Printing a string Backward) Write a program that...Ch. 21 - (Alphabetizing Animal Names) Write a program that...
Ch. 21 - Prob. 21.14ECh. 21 - Prob. 21.15ECh. 21 - Prob. 21.16ECh. 21 - Prob. 21.17ECh. 21 - Prob. 21.18ECh. 21 - (Erasing Characters from a string) Write a program...Ch. 21 - Prob. 21.20ECh. 21 - Prob. 21.21ECh. 21 - Prob. 21.22ECh. 21 - Prob. 21.23ECh. 21 - Prob. 21.24ECh. 21 - Prob. 21.25ECh. 21 - (Cooking with Healthier Ingredients) Obesity in...Ch. 21 - Prob. 21.27MADCh. 21 - (SMS Language) Short Message Service (SMS) is a...
Knowledge Booster
Similar questions
- Give an example of a while loop, then provide the equivalent do-while loop and for loop. Then give a different example of a do-while loop, along with the equivalent while loop and for loop. Finally, give an example of a for loop, along with the equivalent while loop and do-while loop. Use your examples to illustrate the advantages and disadvantages of each looping structure, and describe those advantages and disadvantages.arrow_forwardAUTOLISP Question: Use the defun, setq, polar, getpoint, command and arithmetic functions (*,+,-./) to write a program that will draw an "I" beam cross-section.arrow_forwardFill in the blanks: Q. Expansion of PIO in programming is_____________.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning