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

while initialization of array why we use a[][2] why not a[2][]...?

1863


What is the process of writing the null pointer?

607


What is the use of void pointer and null pointer in c language?

625


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

592


What is the usage of the pointer in c?

606






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...

1485


Write a factorial program using C.

643


how to create duplicate link list using C???

2073


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

615


What is a null string in c?

585


What is the purpose of main( ) in c language?

617


What are the types of i/o functions?

677


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5198


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2118


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

653