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 we assign string to char pointer?
How can I automatically locate a programs configuration files in the same directory as the executable?
What are multibyte characters?
What is n in c?
How many main () function we can have in a project?
What is the best way to store flag values in a program?
What is the use of a conditional inclusion statement in C?
Is array name a pointer?
How do you determine the length of a string value that was stored in a variable?
Why can arithmetic operations not be performed on void pointers?
Explain the difference between structs and unions in c?
What is a structure and why it is used?
Difference between pass by reference and pass by value?
What are file streams?
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell