write a program of palindrome(madam=madam) using pointer?

Answer Posted / pradeep raj

int main()
{
char a[20],*p,*q;//p=>front pointer q=>back pointer
int flag=0;
cin >>a;
q=&a[0];
while(*q!='\0')
q++;
q--; // to the last character before null

for(p=&a[0];p!=q ;p++,q--)
{

if(*p==*q)
flag++;
if((q-p)==1)//to avoid even palindrome..
break;

}
if(flag==strlen(a)/2)
cout <<" is palindrome";
else
cout <<"not";
getch();

}

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me about low level programming languages.

843


Is c++ based on c?

821


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

1801


Is there a way to jump out of a function or functions?

820


using for loop sum 2 number of any 4 digit number in c language

1957


How do we declare variables in c?

773


What are c identifiers?

830


What is pass by value in c?

758


How do you determine a file’s attributes?

788


What is formal argument?

855


What do you understand by friend-functions? How are they used?

904


Why should I prototype a function?

816


What is use of bit field?

981


write a proram to reverse the string using switch case?

2666


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1638