#include<iostream.h>
#include<string.h>
void main()
{
char str[80];
int i,j,flag;
cout<<"enter a string : ";
cin.getline(str,80);
for(int len=0;str[len]!='\0';len++)
flag=0;
for(i=0,j=len-1;i<len/2;i++,j--)
{
if(str[i]==str[j])
{
flag=1;
break;
}
}
if(flag==1)
cout<<"\nstring is palindrome";
else
cout<<"not";
}
No comments:
Post a Comment