#include<iostream.h>
#include<conio.h>
#define size 50
class numchar
{
int len;
public:
char s[size];
int parlindrom();
};
int numchar::parlindrom()
{
for(len=0;s[len]!='\0';len++);
int i,j;
for(i=0,j=len-1;i<len;i++,j--)
if(s[i]!=s[j])
return 0;
return 1;
}
int main()
{
clrscr();
numchar x;
cout<<"Enter the String or number :";
cin>>x.s;
if(x.parlindrom())
cout<<"\tis parlindrom";
else
cout<<"\tis not parlindrom";
getch();
return 0;
}
0 comments:
Post a Comment