C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 21, Problem 21.21E
Program Plan Intro
Printing a String Backward Using Recursion.
- Include the required header files.
- Declare the prototype of the function recursive.
- Define the “recursive()” function.
- Check whether str.rend()==rit.
- If so then return.
- Else display the current text at rit.
- Make a call to function recursivewithstrand the next location.
- Define the “main()” function
- Create a string variable str.
- Accept a line of text from user into str.
- Display the original value of str variable.
- Display the message “The reversed one is :”.
- Make a call to function recursivewithstrand a string iterator.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
DO NOT COPY FROM OTHER WEBSITES
Correct and detailed answer will be Upvoted else downvoted. Thank you!
Recursion Practice
Welcome back! In this lab, we will be reviewing recursion by practicing with some basic recursion problems.
Objectives
Increase familiarity with recursive logic by working through several recursive problems.
Taking into consideration a few corner cases through analyzing the test cases.
Using a regex expression that will remove punctuation.
Getting Started
This lab includes the following .java file:
L4/└── Recursion.java└── Main.java**Main.java is a read-only file used for testing. It is not included in the starter jar.Here is the starter jar if you would like to code in a different environment: L4.jar.
Please complete ALL functions. Make sure to read the description for each function carefully.
Do not include any for or while loops in your methods. These can all be completed in a purely recursive style, so do it recursively!
In the spirit of incremental development, implement each method one at a time, look at the test cases and take into consideration what is…
Problem 2 -- Recursive Palindrome (Grey + Scarlet)
Write a recursive method, isPalindrome, which takes a String
as a parameter, and returns true if the String is a palindrome.
For the purposes of this method, you may assume Strings
with a length of o or 1 are palindromes.
Chapter 21 Solutions
C++ How to Program (10th Edition)
Ch. 21 - Prob. 21.4ECh. 21 - Prob. 21.5ECh. 21 - (Find Code Error) Find any errors in the following...Ch. 21 - (Simple Encryption) Some information on the...Ch. 21 - Prob. 21.8ECh. 21 - Prob. 21.9ECh. 21 - (String Concatenation) Write a program that...Ch. 21 - (Hangman Game) Write a program that plays the game...Ch. 21 - (Printing a string Backward) Write a program that...Ch. 21 - (Alphabetizing Animal Names) Write a program that...
Ch. 21 - Prob. 21.14ECh. 21 - Prob. 21.15ECh. 21 - Prob. 21.16ECh. 21 - Prob. 21.17ECh. 21 - Prob. 21.18ECh. 21 - (Erasing Characters from a string) Write a program...Ch. 21 - Prob. 21.20ECh. 21 - Prob. 21.21ECh. 21 - Prob. 21.22ECh. 21 - Prob. 21.23ECh. 21 - Prob. 21.24ECh. 21 - Prob. 21.25ECh. 21 - (Cooking with Healthier Ingredients) Obesity in...Ch. 21 - Prob. 21.27MADCh. 21 - (SMS Language) Short Message Service (SMS) is a...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Explain the difference between the following with simple example 1. plot and plot3. 2. H1 line and help text line. 3. Nested function and recursion. Aarrow_forwardIdentify the base case in this recursive function. Assume i> 0 when the function is invoked. (Line numbers are not part of the code.) 1. def add(i, j): 2. if i == 0: 3. return j 4. else: 5. return add(i - 1, j + 1) This function has no base case O line 5 line 1 line 4 O line 2 Question 6 The following recursive function is supposed to return a list that is the reverse of the list it was given. But it has a bug. What is the bug? (Line numbers are not part of the code.) MooP eok Drarrow_forwardPlease, answer and give an explanation of the answer.arrow_forward
- Which of the following statements are correct? Iteration is always worse than recursion. Recursion uses more memory than an iterative approach. Recursion uses less memory than an iterative approach. O Iterative function is always easier to write than recursion.arrow_forwardCalculation "a" was used for loop to calculate the sum of squares of values in this list: 1, 7, 8, 6, 11 (The answer was 271) (Question 1) Create recursive function to do the same calculation "a" in the above. (The function input will be the list. Each recursion, you are going to send a sub-list with one less item from the list) (Hint:There are many ways to do sorting. Create a function to perform bubble sorting as descried in this tutorial: (https://www.geeksforgeeks.org/bubble-sort/) . The algorithm should stop when there are no swaps in the last iteration.)arrow_forwardWrite a recursive function to compute the following series:arrow_forward
- Python only** Use recursive function* Define countBetween with 2 parameters Use def to define countBetween with 2 parameters thas two parameters: a starting number and an ending number, and counts up (i.e., prints consecutive integers) from the starting number to the ending number. If the numbers are the same, it just prints that number; if the ending number is lower than the starting number, it prints nothing. Do not use any kind of loop Within the definition of countBetween with 2 parameters, do not use any kind of loop. Call countBetween Within the definition of countBetween with 2 parameters, call countBetween in at least one place. Python only** Use recursive function* Define countThereAndBack with 2 parameters Use def to define countThereAndBack with 2 parameters after reaching the ending number, it also counts back down to the starting number. It accepts the same two parameters defining starting and ending numbers it should print nothing if the starting number is…arrow_forward: Write a recursive function to multiply two positive integers without usingthe * operator (or / operator). You can use addition, subtraction, and bit shifting, but you shouldminimize the number of those operations.arrow_forwardWrite a recursive function that displays the number of even and odd digits in an integer using the following header: void evenAndOddCount(int value) Write a test program that prompts the user to enter an integer and displays the number of even and odd digits in it.arrow_forward
- 12:09 9 & K all 86%i Asgn5 Part 2- recursion For this part, you have 2 small programs to write (independent of each other). In both cases, write only one class, with one recursive static method and one main method. The main method should have some example code showing how the recursive method is called, with hardcoded values. 1. Write a recursive method that calculates the total space used by all files under a given folder (or directory), including all files that are accessible from it when traversing down some subfolders. Here are some methods that could help you here, that are part of the class "File": isFile() : returns true if the file is a regular file (not a directory) isDirectory() : returns true if the file is a directory length() : returns a value of type "long" (not int), that is the number of bytes taken by the file. Note that it has to be called on a normal file only, not on a directory. listFiles() : called on a directory, it returns an array of File objects corresponding…arrow_forward6) Write a recursive function to calculate the summation of numbers from 1 to n. For exampleif the user enters 5, your program would add 1+2+3+4+5 and print out the answer 15.7) Write a recursive program to calculate Fibonacci numbers. Use the definition of a Fibonaccinumber where F(n) = F(n-1) + F(n-2). use java to codearrow_forwardProvide JAVA source code with proper comments for attached assginment.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License