Monday, September 1, 2008

Palindrome

#include"conio.h"
#include"string.h"
#include"stdio.h"
void main()
{
clrscr();
char a[20];
int i=0,j,flag;
printf("\n Enter the string\n");
gets(a);
j=strlen(a)-1;
while(i<=j) {
if(a[i]==a[j])
flag=0;
else{
flag=-1;
printf("string is not a palindrome");
break;
}
i++;
j--;
}
if(flag==0){
printf("string is a palindrome");
}
getch();
}

0 comments: