Sunday, February 14, 2010

To Check Whether a String is a Palindrome

#include
#include
#include
void main(void)
{
char a[50],b[50];
clrscr();
printf("Enter the string:");
gets(a);
strcpy(b,a);
strrev(a);
if(strcmp(b,a) == 0)
{
printf("The given string is a palindrome!!!");
}
else
{
printf("The given string is not a palindrome!!!");
}
getch();
}

No comments: