program to find Polindrome(string) without using String function?

by Ranganathan 2012-08-28 10:42:54

#include <stdio.h>
#include <string.h>

void main()
{
char text[100];
int begin, middle, end, length = 0;

gets(text);

while ( text[length] != '\0' )
length++;

end = length - 1;
middle = length/2;

for( begin = 0 ; begin < middle ; begin++ )
{
if ( text[begin] != text[end] )
{
printf("Not a palindrome.\n");
break;
}
end--;
}
if( begin == middle )
printf("Palindrome.\n");

return 0;
}
767
like
0
dislike
0
mail
flag

You must LOGIN to add comments