C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
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.

Blurred answer
Students have asked these similar questions
Design and draw a high-level "as-is" process diagram that illustrates a current process related to a product or service offered through the SSDCI.gov database.
Compare last-mile connections for connecting homes and businesses to the Internet
Explain wireless networking standards
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning