#include<iostream>
using namespace std;
int main()
{
char name[30];
cout<<"Enter the string:";
gets(name);
int len=strlen(name);
cout<<"\n\nThe length of the string is: "<<len;
int i,j;
char temp;
int flag=1;
for(i=0,j=len-1;i<=len/2;++i,--j)
{
temp=name[i];
name[i]=name[j];
name[j]=temp;
if(name[i]!=name[j])
{
flag=0;
break;
}
}
cout<<"\n\nThe reversed string is: "<<name;
if(flag)
cout<<"\n\nIt is palindrome!!!!!\n\n\n";
else
cout<<"\n\nIt is not a Palindrome!!!!!\n\n";
return 0;
}
using namespace std;
int main()
{
char name[30];
cout<<"Enter the string:";
gets(name);
int len=strlen(name);
cout<<"\n\nThe length of the string is: "<<len;
int i,j;
char temp;
int flag=1;
for(i=0,j=len-1;i<=len/2;++i,--j)
{
temp=name[i];
name[i]=name[j];
name[j]=temp;
if(name[i]!=name[j])
{
flag=0;
break;
}
}
cout<<"\n\nThe reversed string is: "<<name;
if(flag)
cout<<"\n\nIt is palindrome!!!!!\n\n\n";
else
cout<<"\n\nIt is not a Palindrome!!!!!\n\n";
return 0;
}
0 comments:
Post a Comment