c program to check whether a string is palindrome or not with user defined functions. does anyone know pls i have test tomorrow
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.
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).
I mean to say `n = strlen( string )`.
Join our real-time social learning platform and learn together with your friends!