Friday, March 20, 2009

SIMPLEST PALINDROME

#include
#include
void main()
{
char line[50],word[50],tmp[50],c;
int count=0,i=0,j=0;
clrscr();
printf("enter the sentence\n");
gets(line);
do
{
c=line[i];
if (c==' '||c=='\0')
{
word[j]='\0';
strcpy(tmp,word);
strrev(tmp);
if(strcmp(word,tmp)==0)
{
count+=1;
}
i++;
j=0;
}
else
{
word[j]=c;
i++,j++;
}
}
while(c!='\0');
printf("no.of palin=%d",count);
getch();

}

No comments:

Post a Comment