Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 14, Problem 7PC
Program Plan Intro
String Reverser
- Include the required header files to the program.
- Declare function prototype.
- Define the “main()” function. Inside this function,
- Declare an array of character named “word[]”.
- Get a word from the user and store it in a variable “word”.
- Print the reversed string by calling the function “print_Reverse()”.
- Return the statement.
- Give function definition for “print_Reverse()”.
- Check if the string “s” is not null.
- Call the function “print_Reverse()” recursively.
- Print the first character in the last position.
- Check if the string “s” is not null.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Recursive PrintingDesign a recursive function that accepts an integer argument,n , and prints the numbers 1 up through n .
Exponent
y Catherine Arellano
mplement a recursive function that returns
he exponent given the base and the result.
for example, if the base is 2 and the result is
3, then the output should be 3 because the
exponent needed for 2 to become 8 is 3 (i.e.
23 = 8)
nstructions:
1. In the code editor, you are provided
with a main() function that asks the
user for two integer inputs:
1. The first integer is the base
2. The second integer is the result
2. Furthermore, you are provided with the
getExponent() function. The details of
this function are the following:
1. Return type - int
2. Name - getExponent
3. Parameters
1. int - base
2. int - result
4. Description - this recursive function
returns the exponent
5. Your task is to add the base case and
the general case so it will work
Score: 0/5
Overview
1080
main.c
exponent.h
1 #include
2 #include "exponent.h"
3 int main(void) {
4
int base, result;
5
6
printf("Enter the base: ");
scanf("%d", &base);
7
8
9
printf("Enter the result: ");…
Recursive Power FunctionWrite a function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised and the exponent. Assume that the exponent is a nonnegative integer. Demonstrate the function in a program.
SAMPLE RUN #0: ./recursiveExponent
Hide Invisibles
Highlight: Show Highlighted Only
2^3=8↵ 2^4=16↵ 3^3=27↵ 6^3=216↵ 7^7=823543↵ 10^9=1000000000↵
Chapter 14 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 14.1 - What is a recursive functions base case?Ch. 14.1 - What happens if a recursive function does not...Ch. 14.1 - Prob. 14.3CPCh. 14.1 - What is the difference between direct and indirect...Ch. 14 - What type of recursive function do you think would...Ch. 14 - Which repetition approach is less efficient; a...Ch. 14 - When should you choose a recursive algorithm over...Ch. 14 - Prob. 4RQECh. 14 - Prob. 5RQECh. 14 - Prob. 6RQE
Ch. 14 - Predict the Output 7. What is the output of the...Ch. 14 - Soft Skills 8. Programming is communication; the...Ch. 14 - Prob. 1PCCh. 14 - Recursive Conversion Convert the following...Ch. 14 - Prob. 3PCCh. 14 - Recursive Array Sum Write a function that accepts...Ch. 14 - Prob. 5PCCh. 14 - Recursive Member Test Write a recursive Boolean...Ch. 14 - Prob. 7PCCh. 14 - Prob. 8PCCh. 14 - Ackermanns Function Ackermanns function is a...Ch. 14 - Prefix to Postfix Write a program that reads...Ch. 14 - Prob. 11PCCh. 14 - Prob. 12PC
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
- 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 7* 4 = 4 + 4 + 4 +4 + 4 + 4 + 4arrow_forward*C Language The greatest common divisor of integers x and y is the largest integer that divides both x and y. Write a recursive function GCD that returns the greatest common divisor of x and y. The GCD of x and y is defined as follows: If y is equal to zero, then GCD(x, y) is x; otherwise GCD(x, y) is GCD(y, x % y) where % is the remainder operator.arrow_forward2. Sum: a recursive function that computes the sum of integers 1, 2, 3, …., n for a given number n. So Sum(6) should return 1 + 2 + 3 + 4 + 5 + 6 , i.e. 21.sum(n) = n + sum(n-1)arrow_forward
- 7. Recursive Power Method In Python, design a function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised, and the exponent. Assume the exponent is a nonnegative integer.arrow_forwardWrite a recursive function that converts a decimal number into a hex number as a string. The function header is: string decimalToHex(int value) Write a test program that prompts the user to enter a decimal number and displays its hex equivalent.arrow_forwardWrite a recursive function that converts a decimal number into a binary number as a string. The function header is: string decimalToBinary(int value) Write a test program that prompts the user to enter a decimal number and dis- plays its binary equivalent.arrow_forward
- C PROGRAMarrow_forwardPYTHON RECURSIVE FUNCTION Write a python program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names, then use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Juliaarrow_forwardInstructions: In the code editor, you are provided with a main() function that asks the user for a string and passes this string and the size of this string to a function call of the function, preserveString(). This preserveString() function has the following description: Return type - void Name - preserveString Parameters The string Length of the string Description - this is a recursive function that prints the string repeatedly. Each time it prints the string, it excludes the last character of the string until only one character is left. This preserveString() function has already been partially implemented. Your only task is to add the recursive case of this function. Please Finish the code ASAP: This is my current given code: #include<stdio.h>#include<string.h> #define STR_MAX_SIZE 100 void preserveString(char*, int); int main(void) { char str[STR_MAX_SIZE]; printf("Enter string: "); fgets(str, STR_MAX_SIZE, stdin); preserveString(str,…arrow_forward
- Computer science C prog Create a recursive function that finds if a number is palindrome or not(return true or false), A palindromic number is a number (such as 16461) that remains the same when its digits are reversed. In the main function asks the user to enter a number then check if it's palindrome or not using the function you created previously.arrow_forwardWrite a recursive function that parses a hex number as a string into a decimal integer. The function header is: int hexToDecimal(const string& hexString) Write a test program that prompts the user to enter a hex string and displays its decimal equivalent.arrow_forwardQuestion 1 Not complete Marked out of 1.00 Flag question Write a recursive function named count_non_digits (word) which takes a string as a parameter and returns the number of non-digits in the parameter string. The function should return 0 if the parameter string contains only digits. Note: you may not use loops of any kind. You must use recursion to solve this problem. You can assume that the parameter string is not empty. For example: Test Result print(count_non_digits ('123')) print(count_non_digits ('2rPTy5')) print(count_non_digits ('hello world')) 11 Precheck Check 0 4 Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) 1arrow_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