Question
for c++ 1)Write a program that prompts the user to input a string of characters. 2)each character is pushed on a stack Therefore a stack
for c++
1)Write a program that prompts the user to input a string of characters.
2)each character is pushed on a stack
Therefore a stack class must be declared in a stack.h file.
3) each character is also placed in a character array named: letters
4) the characters are then popped off the stack and displayed on the screen.
By doing so, the input string is displayed in reverse order, because the first character popped off the stack is the last letter of the input string.
5) as each character is being popped off the stack, it is compared to the characters in the letters array.
-therefore, as the process begins, the first character in the letters array is compared to the first letter popped off the stack(which is actually the letter in the input string)
6) the process of popping and comparing continues until the stack is empty
7) if all of the characters popped match all the characters in the letters array, then an output statement says that the input string is a palindrome
-otherwise, it states that its not a palindrome
Two user functions: getstring and isPalindrome
getstring() function prompts the user to enter a string
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started