/*A program to check whether a string ia a palindrome or not*/
#include <stdio.h>
int 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("is not a palindrome.\n");
break;
}
end--;
}
if( begin == middle )
printf("is a Palindrome.\n");
return 0;
}
No comments:
Post a Comment