Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What language is c written?

1039


When would you use a pointer to a function?

1035


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

1085


Which is more efficient, a switch statement or an if else chain?

1012


Is c dynamically typed?

1147


What is meant by 'bit masking'?

1384


Why we use conio h in c?

1213


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1277


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.

2083


How can I get back to the interactive keyboard if stdin is redirected?

1179


Explain how do you convert strings to numbers in c?

1073


Explain logical errors? Compare with syntax errors.

1066


What is n in c?

1024


What is the difference between near, far and huge pointers?

1083


Where are some collections of useful code fragments and examples?

1152