#include<string.h>
int check_palindrome( char s[])
{
char reverse[100], temp ;
int i, j ;
strcpy(reverse, s);
printf("\n string = %s", reverse) ;
for ( i = 0, j = strlen(reverse) -1; i<j; i++, j--)
{
temp = reverse[i];
reverse[i] = reverse[j];
reverse[j] = temp;
}
printf("\n Reverse string = %s", reverse) ;
if( !strcmp(s, reverse) )
return 1;
else
return 0;
}
int main()
{
char str[100], temp, reverse[100];
int i, j = 0, res =0;
printf("\n Enter string \n");
gets(str);
res = check_palindrome(str);
printf("\n res = %d", res);
return 0;
}
No comments:
Post a Comment