Check whether given string is palindrome or not

If the reverse of any string is equivalent to the original string then it is called palindrome.For eg,the reverse of madam is madam.So the string madam is palindrome string. In this programe,the first and last character of the string are compared.If they match then the adjacent characters are compared.This process continous until the characters match with each other.If at any position mismatch occurs then it is not a palindrome.

Array str is used for storing the string.For comparing the end characters, variables i and j are used.When the characters at i and j poistion matches,then i is incremented by 1 and j is decremented by 1.The function palin is called again with the incremented i and decemented j.This process continous until i is less than j.But if at any position mismatch occurs then 0 is returned and string is not a palindrome.If 1 is returned then string is palindrome.

#include < stdio.h >
#include < conio.h > 
int palin(char str[],int i,int j);
void main()
{
	char str[100];
	int i,j,reply;	
	clrscr();
	printf("\nEnter a string \n");
	gets(str);
	//... locate last character
	j = 0;
	while ( str[j] != '\0')
	{
		j++;
	} // while
	j--;
	i=0;
	reply = palin(str,i,j);
	if( reply == 0 )
		printf("\n %s is not palindrome",str);
	else
		printf("\n %s is palindrome",str);
}//main
int palin(char str[],int i,int j)
{
	if (i < j )
	{
		if ( str[i] != str[j])
			return(0);
		else
			return(palin(str,i+1,j-1));
	}
	else
		return(1);
} // main