Question: #include #include #include #define MAX _ LENGTH 2 0 0 bool isPalindrome ( char * str ) { char * start = str; char *

#include
#include
#include
#define MAX_LENGTH 200
bool isPalindrome(char *str){
char *start = str;
char *end = str;
// Move 'end' to the last character
while (*end !='\0'){
end++;
}
end--;
while (start < end){
// Skip non-alphanumeric characters
while (!isalnum(*start) && start < end){
start++;
}
while (!isalnum(*end) && start < end){
end--;
}
// Compare characters case-insensitively
if (tolower(*start)!= tolower(*end)){
return false; // Not a palindrome
}
start++;
end--;
}
return true; // Palindrome
}
int main(){
char input[MAX_LENGTH];
printf("Enter a word/phrase: ");
if (fgets(input, MAX_LENGTH, stdin)== NULL){
printf("Error reading input
");
return 1;
}
if (isPalindrome(input)){
printf("The word/phrase is a palindrome.
");
} else {
printf("The word/phrase is not a palindrome.
");
}
return 0;
}
Edit this c program so it no longer uses

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!