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 a storage class?

651


What are dynamic type checking?

624


What are pointers used for c++?

587


Differentiate between a template class and class template in c++?

638


What is the latest c++ version?

619






What is the main purpose of overloading operators?

597


what you know about c++?

675


Write about the use of the virtual destructor?

622


Can we make any program in c++ without using any header file and what is the shortest program in c++.

627


What is c++ array?

563


Which programming language's unsatisfactory performance led to the discovery of c++?

824


What is c++ vb?

618


Write a function to find the nth item from the end of a linked list in a single pass.

578


Explain method of creating object in C++ ?

607


What are the two main components of c++?

601