Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Give a physical interpretation of curl.

Answered: 1 week ago

Question

=+4. Consider competitors' campaigns. How could yours stand out?

Answered: 1 week ago

Question

5. Discuss the role of the Web in career management.

Answered: 1 week ago

Question

4. Design a career management system.

Answered: 1 week ago