#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int main()
{ void palcheck(char str[]);
char ans;
char str[20];
do
{
cout<<"Enter the string to check if it is a palindrome. ";
gets(str);
palcheck(str);
cout<<"\nEnter Y to continue. ";
cin>>ans;
}while (ans=='y'||ans=='Y');
}
void palcheck(char str[])
{ int l=0,k=0,flag;
for(int i=0;str[i]!='\0';i++)
l=l+1;
k=l;
for(int j=0;j<l/2;j++)
{
k--;
if(str[j]==str[k])
flag=1;
else
{flag=0;
break;}
}
if(flag==0)
cout<<"\nString is not a palindrome. ";
else cout<<"String is a palindrome. ";
}
i am almost done . just a small error. it is not asking for new input which i want it to do . it is storing the previous value. some problem around the do loop but not able to figure out. i think it has to do something with declaration of variable.