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

Can we assign string to char pointer?

1115


How can I automatically locate a programs configuration files in the same directory as the executable?

1170


What are multibyte characters?

1131


What is n in c?

1057


How many main () function we can have in a project?

1115


What is the best way to store flag values in a program?

1081


What is the use of a conditional inclusion statement in C?

1067


Is array name a pointer?

1035


How do you determine the length of a string value that was stored in a variable?

1125


Why can arithmetic operations not be performed on void pointers?

1046


Explain the difference between structs and unions in c?

1028


What is a structure and why it is used?

1229


Difference between pass by reference and pass by value?

1161


What are file streams?

1020


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

2178