Fri Nov 07, 2008 5:29 pm
Fri Nov 07, 2008 5:32 pm
#include <stdio.h>
#define PALINDROME 0
#define NOT_PALINDROME 1
main()
{
char buff[512];
printf("Enter a string: ");
scanf("%s", buff);
if (palindrome(buff) == PALINDROME) {
printf("String is palindrome\n");
}
else {
printf("String is not a palindrome\n");
}
}
int palindrome(char *ptr)
{
int strbeg = 0, strend = 0;
strend = strlen(ptr) - 1;
while ( strbeg == strend || strbeg < strend) {
if (ptr[strbeg] != ptr[strend])
return (NOT_PALINDROME);
strbeg++;
strend--;
}
return (PALINDROME);
}
|
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.