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 an accessor in c++?
Is it possible for a member function to delete the pointer, named this?
What do you mean by global variables?
Write an algorithm that determines whether or not an almost complete binary tree is a heap.
What is type of 'this' pointer?
What do you understand by pure virtual function? Write about its use?
What is purpose of new operator?
What are all predefined data types in c++?
Explain virtual destructor?
How do you add an element to a set in c++?
How can you quickly find the number of elements stored in a static array?
What are virtual functions in c++?
Define a constructor - what it is and how it might be called (2 methods)?
Which is most difficult programming language?
Do the parentheses after the type name make a difference with new?