A palindrome string reads exactly the same forwards and backwards, like "level" or "abba". Write is_palindrome(s): return true if it is one, false if not. Upper and lower case are different ("Aba" is not a palindrome); an empty string or one character counts as a palindrome.
is_palindrome("level")→Trueis_palindrome("ab")→Falseis_palindrome("")→Truebool is_palindrome(const char *s)#include <stdbool.h>
#include <string.h>
bool is_palindrome(const char *s) {
int i = 0;
int j = (int)strlen(s) - 1;
while (i < j) {
// your code here: if the two end characters differ, it is not a palindrome
i++;
j--;
}
return true;
}
Run tries the examples. When they look right, Submit.