#include <stdio.h>
#include <string.h>
int isPalindrome(const char* str)
{
int i = 0;
int j = strlen(str) - 1;
while (i < j)
{
if (str[i] != str[j])
{
return 0; // Not a palindrome
}
i++;
j--;
}
return 1; // Palindrome
}
int main()
{
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
// Remove newline character from fgets input
str[strcspn(str, "\n")] = '\0';
if (isPalindrome(str))
{
printf("The string is a palindrome.\n");
}
else
{
printf("The string is not a palindrome.\n");
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: