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
Tell me about low level programming languages.
Is c++ based on c?
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
Is there a way to jump out of a function or functions?
using for loop sum 2 number of any 4 digit number in c language
How do we declare variables in c?
What are c identifiers?
What is pass by value in c?
How do you determine a file’s attributes?
What is formal argument?
What do you understand by friend-functions? How are they used?
Why should I prototype a function?
What is use of bit field?
write a proram to reverse the string using switch case?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?