C Program
A palindrome consists of a word or deblanked, unpunctuated phrase that is spelled exactly the same when the letters are reversed. Write a recursive function that returns a value of 1 if its string argument is a palindrome. Notice that in palindromes such as level, deed, sees, and Madam I'm Adam (madamimadam), the first letter matches the last, the second matches the next-to-last, and so on.
#include <stdio.h>
#include <string.h>
int is_palindrome(char str[], int start, int end) {
if(start < end) {
return str[start] == str[end] && is_palindrome(str, start + 1, end - 1);
} else {
return 1;
}
}
int main() {
char str[100];
while(1) {
printf("Enter a string: ");
scanf("%s", str);
if(strcmp(str, "STOP") == 0 || strcmp(str, "stop") == 0 || strcmp(str, "Stop") == 0) {
break;
}
if(is_palindrome(str, 0, strlen(str)-1)) {
printf("%s is a palindrome\n", str);
} else {
printf("%s is not a palindrome\n", str);
}
}
return 0;
}
C Program A palindrome consists of a word or deblanked, unpunctuated phrase that is spelled exactly...