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
What language is c written?
When would you use a pointer to a function?
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
Which is more efficient, a switch statement or an if else chain?
Is c dynamically typed?
What is meant by 'bit masking'?
Why we use conio h in c?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
How can I get back to the interactive keyboard if stdin is redirected?
Explain how do you convert strings to numbers in c?
Explain logical errors? Compare with syntax errors.
What is n in c?
What is the difference between near, far and huge pointers?
Where are some collections of useful code fragments and examples?