Create a new file called 'palindrome.c' and copy the starter code here into it.
An palindrome is a string which contains the same characters going forward and backwards.
Implement the is_palindromic
function in is_palindromic.c
to return true if a given input line is a palindrome, and false if it is not.
But we have a problem, our computer is a tsundere and doesn't want you to use any loops at all!
So, we must implement is_palindromic
without any loops. Though you are free to make any extra functions you want (provided they also do not contain loops).
The output from your program should look exactly like this:
$ gcc is_palindromic.c -o is_palindromic
$ ./is_palindromic
Enter a line: racecar
The line is a palindrome!
$ ./is_palindromic
Enter a line:
The line is a palindrome!
$ ./is_palindromic
Enter a line: racecars
The line is not a palindrome!
$ ./is_palindromic
Enter a line: maam
The line is a palindrome!
$ ./is_palindromic
Enter a line: eeteee
The line is not a palindrome!
if a string is a single character then it is always a palindrome, and you can easily figure out if a two-character string is a palindrome with a single comparison
if a string is a palindrome, what can we say about the substring that excludes the left-most and right-most letter?
for a string to be a palindrome, the left-most and right-most letter must be the same, and the substring excluding those two letters must be palindromic
You can view the solution code to this problem here.