You are on page 1of 1

Write a code for the following scenario:

Input: a line
Output: whether the input is palindrome or not
The code should contain
(i) a recursive function is_palindrome that returns true if the input line is a
palindrome and returns false otherwise
(ii) a main method to that takes as input from user a line and uses the function
is_palindrome to check if the line is a palindrome or not

Sample Input Sample Output


abccba Palindrome
abc cc cba Palindrome
Abc ac Not palindrome
Sore was I ere I saw Eros Palindrome
A man, a plan, a canal -- Palindrome
Panama
Never a foot too far, even Palindrome
I am Fariha Not palindrome

Hint: to find the correct answer for all the sample input, you need to delete everything from the
input string except letters and numbers (a-zA-Z0-9) and convert the uppercase to lowercase.
Your code is valid only if it compiles properly. No marks for invalid code.

You might also like