write program for palindrome

Answer Posted / niruj

/* without using string.h library */
#include<stdio.h>
#include<conio.h>
void main()
{
char *p;
char a[]="malyalam";
char rev[10];
int i;
int len=sizeof(a);
p=a;
do{
p++;
}while(*p!=NULL);
*p='\0';
i=0;
do{
p--;
rev[i]=*p;
i++;
}while(p!=a);
for(i=0;i<=len-2;i++)
{
if(a[i]==rev[i])
{
if(i==len-2)
{
printf("String is Pallindrom");
}
}
else{
printf("String is not pallindrom");
break;
}
}
getch();

}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is atoi in c++?

805


Is c++ vector dynamic?

737


How to access a variable of the structure?

771


How did c++ start?

821


What are the benefits of c++?

776


What can I safely assume about the initial values of variables which are not explicitly initialized?

811


What is oops in c++?

790


What is srand c++?

812


How const int *ourpointer differs from int const *ourpointer?

812


What is the this pointer?

818


How long will it take to learn programming?

789


What are guid?

935


What do you mean by early binding?

782


What is setfill c++?

884


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

820