#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[10],str2[10];
int c;
clrscr();
cout<<"\n Enter string:";
cin>>str1;
strcpy(str2,str1);
strrev(str2);
cout<<"\n Rverse string :"<<str2;
c=strcmp(str1,str2);
if(c==0)
cout<<"\n String is palindrome";
else
cout<<"\n String is not palindrome";
getch();
}
OR
#include<iostream.h>
#include<conio.h>
void main()
{
char src[10], des[10], *sptr, *dptr;
int len=0;
clrscr();
cout<<"\n Enter a string";
cin>>src;
sptr=&src[0];
while(*sptr!='\0')
{
len++;
sptr++;
}
cout<<"\n Length of string is "<<len;
sptr--;
dptr=&des[0];
while(len>0)
{
*dptr=*sptr;
sptr--;
dptr++;
len--;
}
*dptr='\0';
cout<<"\n The Reverse string is "<<des;
sptr=&src[0];
dptr=&des[0];
int flag=0;
while(*dptr != '\0' || *sptr !='\0')
{
if(*dptr == *sptr )
{
flag =0;
}
else
{
flag =1;
break;
}
dptr++;
sptr++;
}
if(flag ==0)
{
cout<<"\nThe String is Palidrome ";
}
else
{
cout<<"\nString is not palindrome";
}
getch();
}