Google Search

Sunday, October 30, 2011

C PROGRAM TOCHECK THAT THE INPUT STRING IS A PALINDROME OR NOT


PROGRAM TOCHECK THAT THE INPUT STRING IS A PALINDROME OR NOT

#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

0 comments:

Post a Comment