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
Why is c called a structured programming language?
What is the need of structure in c?
Why doesnt that code work?
When we use void main and int main?
What is the difference between local variable and global variable in c?
Explain what are preprocessor directives?
Is r written in c?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
How can I write functions that take a variable number of arguments?
What is an auto variable in c?
What are the main characteristics of c language describe the structure of ac program?
Apart from dennis ritchie who the other person who contributed in design of c language.
What is multidimensional arrays
What's the total generic pointer type?
Explain the difference between malloc() and calloc() function?