Question: 2 . Read a phrase and determine whether it is a palindrome or not. Write a c + + program to do the following: a
Read a phrase and determine whether it is a palindrome or not. Write a cprogram to do the following:
a Read the phrase characterbycharacter and store each letters or digits use isalnum function into a linked list pointed by listOriginal
b Find the middle of the listOriginal
c Reverse the second half of the listOriginal insert each element after the middle element in front of new list listRev and delete the element from the listOriginal.
d Compare the new listOrginal with listRev to test the phrase for being a palindrome or not
Sample run:
Enter a phrase: Top Spot
Original list: TopSpotNULL
New original half of the original: TopNULL
The second half in reverse order, listRev: topSNULL
The phrase is a palindrome character by character they are the same with extra S at the end. No matching for S because the number of characters is odd
CONTINUEyn y
Enter a phrase: No on
Original list: NoonNULL
New originalhalf of the original: NoNULL
The second half in reverse order :noNULL
The phrase is a palindrome
CONTINUEyn n
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
