Answered step by step
Verified Expert Solution
Question
1 Approved Answer
TITLE THREE RECURSIVE FUNCTIONS INTRODUCTION Recursion is a programming technique in which a function calls itself. It is another way of implementing repetitive computations, which
TITLE THREE RECURSIVE FUNCTIONS INTRODUCTION Recursion is a programming technique in which a function calls itself. It is another way of implementing repetitive computations, which we have previously associated with loops. When called to solve a problem, a recursive function passes a smaller version (or versions) of the problem to another instance (or other instances) of itself, then uses the results returned by the recursive call or calls to build the solution to the original problem. DESCRIPTION In this project, you are to design, implement, document, and test programs that use recursive functions to solve three problems: writing the digits of an integer in reverse order; computing x"; and determining if an input string is a palindrome. Address these problems individually; that is, in three separate programs. WRITING THE DIGITS OF AN INTEGER BACKWARDS Write and implement a C++ function backwards (n) that writes the digits of its positive integer argument in reverse order. For example, if the value of n is 234567, the function writes the digits 7 6 5 4 3 2. EXPONENTIATION Write and exercise a recursive function exp(x,n) that returns the value of the double x raised to the non-negative integer power n. A run of a program that exercises this function might look like this: Enter a real value: 2.4 Enter an integer: 3 2.4^3 = 13.824 = Remember that any non-zero value raised to the power 0 is 1. DETERMINING IF AN INPUT STRING IS A PALINDROME A palindrome is a string in which the letters are the same in both directions, disregarding capitalization and non-letter characters. For example, "Able was I ere I saw Elba." is a palindrome. Write a program that reads a string of characters and calls a recursive function to determine if the letters in the string form a palindrome. Several runs of the program might look like this: csh> pal Enter a line that might be a palindrome. -> Madam I'm Adam. The string IS a palindrome. csh> pal Enter a line that might be a palindrome. -> Go hang a salami, I'm a lasagna hog. The string IS a palindrome. a a csh> pal Enter a line that might be a palindrome. -> This is another candidate string. The string is NOT a palindrome. Hint: Read the input string into an array one character at a time, using the function get(ch). Keep only the letters and convert each to upper or lower case consistently
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started