I have thes 3 exercises but I have problems with this new argument about recursion in c++:
1) int s (int n) returns the sum of the first n odd numbers
2) int f (int n) returns the sum of the first n natural numbers
3) bool pal (string t) determines if the string t is palindrome.
Can you do a for loop (or a while or do/while loop) to access the individual elements in your string?
Walk from the beginning of the string to the half-way point*, comparing the first and last elements, then the second and second to last elements. Lather, rinse and repeat until you reach the mid-point in your string, or one of the equality comparisons fails and the string isn't a palindrome.
You will have to check for spaces and other non-alphabetic characters and skip over them for your palindrome check.
You also have to be concerned whether the characters being compared have an upper/lower case mismatch.
Creating a copy of the string with only alphabetic characters before you check for palindrome status is also something you can do.
*Why the half-way point? You are comparing elements at both ends, working towards the middle. Going past half-way is excessive since you've already found the string is or isn't a palindrome. If the string has an odd-number of elements then the final check is comparing the middle element with itself.