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
Can you please explain the difference between strcpy() and memcpy() function?
What Is The Difference Between Null And Void Pointer?
Explain how can type-insensitive macros be created?
What is typedf?
Are the outer parentheses in return statements really optional?
shorting algorithmS
What is context in c?
How can you increase the size of a dynamically allocated array?
What are static variables in c?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
Is c language still used?
Write the Program to reverse a string using pointers.
What does *p++ do? What does it point to?
Why does this code crash?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler