palindrome C++ Solved

30.00 $

Categories: ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (4 votes)

Write a program that uses a stack object to determine if a string is a palindrome (i.e. the string is spelled identically backward and forward). The program should ignore spaces and punctuation.

Go ahead and start your program by reading in a C-style string from standard input, using the getline function. You may assume a limit of 100 characters on the string (although this can be written, with a little more effort, to accept any size string). Your algorithm must make use of a stack (of type char). Use the Deitel implementation of the Stack from “stack.h” (you don’t need to change this file).

Ignore spacing and punctuation, as well as special characters and digits (i.e. only count letters as part of a palindrome, and account for upper/lower case. For example, ‘B’ and ‘b’ are matching letters).

Sample runs: (user input underlined)

  Please enter a string:

  "ABCDEFGHGFEDCBA"  IS a palindrome

  Please enter a string:
  > The quick brown fox

  "The quick brown fox"  is NOT palindrome

  Please enter a string:
  > Cigar? Toss it in a can. It is so tragic.

  "Cigar? Toss it in a can. It is so tragic."  IS a palindrome