Saturday, October 26, 2013

Palindrome

Panlindrome check

Program:

#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
char a[20],i,b[20],g=0,j,m;
clrscr();
printf("Enter any string: ");
scanf("%s",a);
for(i=0;a[i]!='\0';i++)
{
g++;
}
j=g-1;
for(i=0;i<g;i++)
{
b[j]=a[i];
j--;
}
for(i=0;i<g;i++)
{
if(b[i]==a[i])
m=0;
else
{
m=1;
break;
}
}
if(m==0)
{
printf("String is a Palindrome");
}
else
if(m==1)
{
printf("String is not a Palindromes");
}
getch();
}

Output:


Enter any string: Madam
String is not a Palindrome


Enter any string: ARORA
String is a Palindrome

No comments: