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
What is atoi in c++?
Is c++ vector dynamic?
How to access a variable of the structure?
How did c++ start?
What are the benefits of c++?
What can I safely assume about the initial values of variables which are not explicitly initialized?
What is oops in c++?
What is srand c++?
How const int *ourpointer differs from int const *ourpointer?
What is the this pointer?
How long will it take to learn programming?
What are guid?
What do you mean by early binding?
What is setfill c++?
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?