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 a storage class?
What are dynamic type checking?
What are pointers used for c++?
Differentiate between a template class and class template in c++?
What is the latest c++ version?
What is the main purpose of overloading operators?
what you know about c++?
Write about the use of the virtual destructor?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What is c++ array?
Which programming language's unsatisfactory performance led to the discovery of c++?
What is c++ vb?
Write a function to find the nth item from the end of a linked list in a single pass.
Explain method of creating object in C++ ?
What are the two main components of c++?