"a man a plan a canal Panama"
YES
#include <stdio.h>
#include <ctype.h>
int main() {
char str[200];
int left = 0, right = 0;
int isPalindrome = 1;
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
// Find length
while (str[right] != '�') {
right++;
}
right--; // last character index
// Remove newline if present
if (str[right] == 'n') {
right--;
}
// Two-pointer comparison
while (left < right) {
if (str[left] == ' ') {
left++;
continue;
}
if (str[right] == ' ') {
right--;
continue;
}
if (tolower(str[left]) != tolower(str[right])) {
isPalindrome = 0;
break;
}
left++;
right--;
}
if (isPalindrome)
printf("The string is a palindrome.n");
else
printf("The string is NOT a palindrome.n");
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main() {
char str[200];
int left = 0, right = 0;
int isPalindrome = 1;
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
// Find length
while (str[right] != '�') {
right++;
}
right--; // last character index
// Remove newline if present
if (str[right] == 'n') {
right--;
}
// Two-pointer comparison
while (left < right) {
if (str[left] == ' ') {
left++;
continue;
}
if (str[right] == ' ') {
right--;
continue;
}
if (tolower(str[left]) != tolower(str[right])) {
isPalindrome = 0;
break;
}
left++;
right--;
}
if (isPalindrome)
printf("The string is a palindrome.n");
else
printf("The string is NOT a palindrome.n");
return 0;
}