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
while initialization of array why we use a[][2] why not a[2][]...?
What is the process of writing the null pointer?
What is the use of void pointer and null pointer in c language?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
What is the usage of the pointer in c?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
Write a factorial program using C.
how to create duplicate link list using C???
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
What is a null string in c?
What is the purpose of main( ) in c language?
What are the types of i/o functions?
#include
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?