Make a program that checks if a given string is palindrome. According to Google, a palindrome is:
Google wrote: |
---|
a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. |
At first your program should ask the user to enter a string of length at most 20 and atleast 2. Then your program should determine if the string the user entered is palindrome. If the string is palindrome, print "YES" otherwise print "NO". Ignore any non alphanumeric characters in the string.
eg:
In: Enter a string: racecar
Out: YES
In: Enter a string: madam, i'm adam
Out: YES
In: Enter a string: maranatha
Out: YES
If you found that too easy, then the next level will be to modify your previous program to first check if the string entered is palindrome, then print the number of palindromes found inside the string. Note that from the definition of palindrome, single characters are considered palindrome, but for this, you can ignore the single character cases.
eg:
In: Enter a string: racecar
Out: YES, 3
In: Enter a string: madam, i'm adam
Out: YES, 9
In: Enter a string: maranatha
Out: NO
If the above 2 haven't scared you away yet, another extension of the first palindrome problem is the problem of reversing a string. You can attempt this if you want
eg:
In: Enter a string: racecar
Out: racecar
In: Enter a string: madam, i'm adam
Out: mada m'i ,madam
In: Enter a string: maranatha
Out: athanaram