hi all!

i need to write a recursive function that checks whether a given
sentence is a palindrome by using this function:
int isPalindrome(char word[]);

i need to define a helper recursive function with extra parameters, and write isPalindrome as a wrapper function.
the helper function is : int isPalindromeHelper(char word[], int size);

note : i should not use global or static variables.

actually my problam is haw to use the helper function .

1. Write the int isPalindromeHelper(char A[],int n) such that it takes a array of char A of a size n and returns 1 if it is a palindrome and 0 it it is not:
isPalindromeHelper("LOLA",3) should return 1 and
isPalindromeHelper("LOLA",4) should return 0

2.Then wrap this function with isPalindrome(char s[]):
isPalindrome checks if the string entered is palindrome by calling isPalindromeHelper(s, strlen(s) ).

If you have any problem in writing the code, try it first and then post it here if it doesn't work. Note that no one is going to write it for you here. :)

why do you need a helper function? seems that all the work is being done there anyhow.

why do you need a helper function? seems that all the work is being done there anyhow.

Because it's part of the assignment. The helper function is undoubtedly supposed to be recursive, checking a character at a time.

oh, jeez. i caint read. :(

do you think that i should creade a new array that takes only the caps letters in the helper function?

the function ispalindrome should also be recursive /

this is my initial code . i know it is not writen well. help me we this.


int help(char word[],int size);
int polindrome(char word[]);

int help(char word[],int size){
///here i try to check if the string is in caps or with signs (@,#,$,%)...

		return 1;
	if( (word[0]==word[size-1]-('A'-'a')) || (word[0]==word[size-1]+('A'-'a'))   )
		return 1;
		return 0;

/// my problem here is that it is not recursive !!!!	

int polindrome(char word[]){
	int length;

        return 1;
//// this is not a good try ' but i hope you can understand what i was trying to do 
		                                ///// can you help me here????
		return palindrome(word+1,length-2);
		return 0 ;


void main(){

	printf("Mad@Am: %d\n" , polindrome("Mad@Am"));
	////should print 1


Not quite. main() should call palindrome() . This you did. palindrome() -- calls palindrome-helper() to check the 1st and last characters.
-- returns the YES or NO back to main() palindrome-helper() starts by checking
-- if no characters left to test, return YES
Then tests the two characters and
-- if same, calls itself with the next two characters (2nd,last-1; etc)
-- if different return NO

thank you !
i understand what you write but the palindrome function that you wrote is not recursive!
they are both should be recursive/
more over , one of the functions should ignore signs and i dont know wich one of them

I doubt both should be recursive.

What signs? One Way signs? Neon signs? Crop Circles? Examples are really helpful.