#include<iostream.h>
#include<conio.h>
#include<string.h>
class Palindrome
{
public:
char str[20];
int len,i,p;
Palindrome()
{
p=0;
}
void input()
{
cout<<"Enter the text"<<endl;
cin>>str;
len=strlen(str);
}
void work()
{
for(i=0;str[i]!='\0';i++)
{
if(str[i]==str[len-1-i])
p++;
}
}
void show()
{
if(p==len)
cout<<"Palindrome";
else
cout<<"Not";
}
};
void main()
{
Palindrome ob;
clrscr();
ob.input();
ob.work();
ob.show();
getch();
}
OUTPUT
#include<conio.h>
#include<string.h>
class Palindrome
{
public:
char str[20];
int len,i,p;
Palindrome()
{
p=0;
}
void input()
{
cout<<"Enter the text"<<endl;
cin>>str;
len=strlen(str);
}
void work()
{
for(i=0;str[i]!='\0';i++)
{
if(str[i]==str[len-1-i])
p++;
}
}
void show()
{
if(p==len)
cout<<"Palindrome";
else
cout<<"Not";
}
};
void main()
{
Palindrome ob;
clrscr();
ob.input();
ob.work();
ob.show();
getch();
}
OUTPUT
No comments:
Post a Comment