Q. What is palindrome?
Ans:Palindrome is a Greek word which is divided in two or three word as (palin=Again + drome/deamein=Run). So A palindrome is word or phrase which reads the same in both direction i.e. left to right and right to left are character must be same. Example of string palindrome as follows :
1. POP
2. MALAYYALAM
3. LEVEL
4. LIVE EVIL
5. MADAM, I'M MADAM
Ans:Palindrome is a Greek word which is divided in two or three word as (palin=Again + drome/deamein=Run). So A palindrome is word or phrase which reads the same in both direction i.e. left to right and right to left are character must be same. Example of string palindrome as follows :
1. POP
2. MALAYYALAM
3. LEVEL
4. LIVE EVIL
5. MADAM, I'M MADAM
/*simple c program to check whether a string is palindrome or not*/
#include<stdio.h>
#include<conio.h>
int main()
{
char str[20];
int i,j;
printf("Enter string : ");
gets(str);
for(i=0; str[i]!=NULL; i++);
for(i--,j=0; j<=i; )
{
if(str[i]==str[j])
{
i--;
j++;
}
else
break;
}
if(j>i)
printf("\nString is palindrome!!");
else
printf("\nString is not palindrome!!");
getch();
getch();
return 0;
}
/****************Output****************
Enter string :navana
String is not palindrome
***************************************/
Enter string : madam n madam
String is palindrome
***************************************/
You might also like:
Comments
Post a Comment