#include <stdio.h>
#include <string.h>
int pali(char *s)
{
char *s2 = s + strlen(s) - 1;
if(!*s) return 0;
while(*(s2--) == *(s++) && *s);
return (!*s && *(++s2) == *(--s));
}
int main()
{
char buff[32];
fputs("Enter the string: ",stdout);
fgets(buff,sizeof(buff),stdin);
*(buff + strlen(buff) - 1) = '\0';
printf("Is the string \"%s\" palindrome?%s\n",
buff,pali(buff)?"YES":"NO");
return 0;
}
#include <string.h>
int pali(char *s)
{
char *s2 = s + strlen(s) - 1;
if(!*s) return 0;
while(*(s2--) == *(s++) && *s);
return (!*s && *(++s2) == *(--s));
}
int main()
{
char buff[32];
fputs("Enter the string: ",stdout);
fgets(buff,sizeof(buff),stdin);
*(buff + strlen(buff) - 1) = '\0';
printf("Is the string \"%s\" palindrome?%s\n",
return 0;
}
No comments:
Post a Comment