# include <iostream.h>
# include<conio.h>
#include<string.h>
int is_palindrome(char* str)
{
int n, flag, i =0;
n= strlen (str);
while(*(str+i)!='\0')
{
if(*(str+i)!=*(str+(n-i-1)))
{
flag = 1;
break;
}
i++;
}
if(flag == 1)
return 0;
else
return 1;
}
void main( )
{
char s[20];
cout<<"\n Enter a String : ";
cin>>s;
if (is_palindrome(s))
cout<<"\n Input string is a palindrome String ";
else
cout<<"\n Input string is not a palindrome String ";
getch( );
}
0 comments:
Post a Comment