Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

c program to check whether a string is palindrome or not with user defined functions. does anyone know pls i have test tomorrow

OpenStudy (rsmith6559):

Palindromes can be checked recursively. Your base case would be the length of the char array is less than 2 ( 0 or 1 characters left ). If the first and last character of the array are equal, just call the function again with the char array[ 1, -1 ]. If they don't match, return false immediately. When you get to the base case, they all have matched so it is a palindrome so you return true.

OpenStudy (anonymous):

I would point indices at the first `0` and last `n-1` positions (where `n=len( string )`). I would move them both closer to the center while checking whether of not the characters are equal (not a palindrome if unequal) and if the indices have passed each other (a palindrome if passed).

OpenStudy (anonymous):

I mean to say `n = strlen( string )`.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!