Hi there,
Just need some help with this small program.
Using recursion I'm trying to find out if a word (in this case a test word) is a palindrome or not. If it is it should return a 1 to result, but instead it shows a big number that looks like a memory address.
Any guide will be deeply apreciated.
# include <stdio.h>
# include <process.h>
# include <string.h>
//Function prototype
int palindrome(char w[],int l,int r);
int
main (void)
{
int left=0;
int right=3;
int result=0;
char word[5]="deed"; //this is a test to check the function
result = palindrome (word,left,right);
printf("The word is %d\n",result ); //if the word is 1 its a palindrome
system("pause"); //if its 0 its not
return (0);
}
//palindrome function
int palindrome (char w [],int l, int r) //get parameters
{
if (r<=l) //base case 1 :we reached the end without problem
{
return (1);
}
else if (w [l] != w [r]) //base case 2 : the letters are not correct
{
return (0);
}
else
{
palindrome (w, (l+1),(r-1)); //recursive formula
}
}