Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 19, Problem 9PC
Program Plan Intro

String Reverser

Program Plan:

  • Include the required header files.
  • Declare the necessary function prototype and constants.
  • Define the main () function.
    • Declare the necessary variables.
    • Get the required input from the user.
    • Call the method “reversestring()” to reverse the string.
    • Display the string after reversing.
  • Define the “reversestring ()” method,
    • Condition that validates the length of the string, if the length of the string is less than “0” it gets returned as an empty string.
    • If the length of the string is greater than “0”, then given string gets reversed and will be displayed.

Blurred answer
Students have asked these similar questions
Recursive PrintingDesign a recursive function that accepts an integer argument,n , and prints the numbers 1 up through n .
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↵
Instructions: 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,…
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning