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
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?
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