Recursion Exercises
-
7.28 (Palindromes) A palindrome is a string that’s spelled the same way forward and backward. Examples of palindromes include “radar” and “able was i ere i saw elba.” Write a recursive function
testPalindrome
that returnstrue
if astring
is a palindrome, andfalse
otherwise. Note that like anarray
, the square brackets ([]
) operator can be used to iterate through the characters in astring
. -
7.29 (Eight Queens) Modify the Eight Queens program you created in Exercise 7.24 to solve the problem recursively.
-
7.30 (Print an
array
) Write a recursive functionprintArray
that takes anarray
, a starting subscript and an ending subscript as arguments, returns nothing and prints thearray
. The function should stop processing ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.