Wednesday, June 25, 2008

PRG TO CHECK WEATHER A STRING IS PALINDROME OR NOT

#include
#include
#include
#include
void main()
{clrscr();
char str[30],flag=0;
int n;
float i;
cout<<"enter the string which is to be checked palindrome";
gets(str);
n=(strlen(str)-1);
for(i=0;i<=n/2;i++)
if(str[i]!=str[n-i])
{ flag=1;}
if(flag==0)
cout<<"palindrome";elsecout<<"not a palindrome" ;
getch();
}

No comments: