#include<stdio.h>
#include<string.h>
int is_palindrom(char S[20],int f,int l)
{
for(;f<=l;f++,l--)
{
if(S[f]!=S[l])
return 0;
}
return 1;
}
int main()
{
char S[20];
int i,l,j,k,count=0;
gets(S);
l=strlen(S);
for(i=0;i<l;i++)
{
for(j=i+1;j<l;j++)
{
if(S[i]==S[j])
if(is_palindrom(S,i,j))
{
printf("\n");
count++;
for(k=i;k<=j;k++)
printf("%c",S[k]);
}
}
}
printf("\n\nTotal << %d >> no of palindrom in given string\n",count);
return 0;
}
Let me know your thoughts.
ur code dosnt excuted in gcc complier it is showing
ReplyDeletestringpalind.c: In function ‘main’:
stringpalind.c:17:5: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(S);
^
/tmp/cclAqc1X.o: In function `main':
stringpalind.c:(.text+0x63): warning: the `gets' function is dangerous and should not be used.