Friday, May 30, 2014

WRITE A PROGRAMME TO FIND WHETHER A STRING IS PALINDROME OR NOT

#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char s1[20];
int i=0,l,j,flag;
clrscr();
printf("enter the string\n");
scanf("%s",s1);
l=strlen(s1);
for(i=0,j=l-1;i<j;i++,j--)
{
if(s1[i]==s1[j])
{
flag=1;
}
else
{
flag=0;
break;
}
}
if(flag==1)
printf("\n%s is pallindrome",s1);
else
printf("\n%s is not a pallindrome",s1);
getch();
}

No comments:

Post a Comment