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
Distinguish between new and malloc and delete and free().
Is map ordered c++?
What is the difference between global variables and local variable
Why do we use iterators?
Can you write a function similar to printf()?
Which is the best c++ compiler for beginners?
What is the difference between structure and class?
Is c++ used anymore?
What is the difference between function overloading and operator overloading?
what is c++
When are exception objects created?
If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?
What are static variables?
What are maps in c++?
Why is c++ so fast?