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 endl?
Explain rtti.
What is the extraction operator and what does it do?
What type of question are asked in GE code writing test based on c++ data structures and pointers?
What is the difference between strcpy() and strncpy()?
Write about the access privileges in c++ and also mention about its default access level?
Which is the best c++ software?
What is the size of a vector?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
why is c++ called oops? Explain
What is function prototyping? What are its advantages?
Why use of template is better than a base class?
declare an array of structure where the members of the structure are integer variable float variable integer array char variable access all elements of the structure using dot operator and this pointer operator
what is the difference between overloading & overriding? give example.
What are the types of array in c++?