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
Difference between overloading vs. Overriding
Why should you learn c++?
What is the difference between prefix and postfix versions of operator++()?
Which is the best c++ compiler for beginners?
Explain the difference between c & c++?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
What is #include cmath?
How does java differ from c and c++?
What is the advantage of an external iterator.
What are the various storage classes in C++?
Why do we use classes in programming?
What is the difference between delegation and implemented-in-terms-of?
What are the two types of comments?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
What are the two shift operators and what are their functions?