Write a function that recursively reverses a string

Assignment Help Computer Engineering
Reference no: EM132164379

Using C++, you will implement three functions using recursion and write a menu program to call these functions.

1. Write a function that recursively reverses a string. The function will have a single parameter of type string. It will print the reversed characters to the screen followed by a newline character.

Before you start writing code, try to answer these questions to yourself. What is the base case? Will you print out the characters before or after the recursive function call? You can try it in both ways and see if it makes a difference and choose one way to use in the function.

2. Write a function that recursively calculates the sum of an array. The function should have 2 parameters, the array and an integer showing the number of elements (assume they are all integers) in the array. The function will use a recursive call to sum the value of all elements.

3. Write a recursive function to calculate the triangular number for N. (Or a function that counts the number of pins necessary for a triangular of N rows.)

A triangular number is the sum of all items that form a triangle with N rows. It may help to think of the number of bowling pins if you changed the number of rows. For example, when N=0, the triangular number is 0; When N=1, the triangular number is 1; When N=2, the triangular number is 1+2=3; When N=3, the triangular number is 1+2+3=6, so on so forth.

You will also need to write a program to demonstrate all three recursive functions. Provide a menu for the user to select which function to run, and after running the function, return to the menu.

For #1, you must prompt the user to enter a string and your program will print the reversed string on screen. For #2, you must prompt for a series of integers to be entered in the array. As your program read the numbers in, increment a count so it knows how many elements the array has.

Use a symbol for users to indicate when they are done with entering numbers (choose any letter you think is proper, but you need to print it on screen at the beginning to let users know which one to enter). Then your program will print the sum of the array elements on screen. For #3, prompt the user to enter an integer and your program will print the triangular number for that integer. You will need a fourth item in the menu to allow them to exit the program.

Reference no: EM132164379

Questions Cloud

What is the probability that i take 7 graphic : 1) What is the probability that I take 7 graphic novels with me on my vacation? 2) What is the probability that I take 3 poetry books and 4 biographies with me
Are co-occurring disorders classified in any particular way : Ensuring delinquent youths receive adequate services when in detention is a crucial step in preventing recidivism. Examples of such services are education.
Explain appropriateness of the risk mitigating strategies : Explain the risk management process applied to the chosen enterprise - explain and evaluate the critical nature and impact of ONE INTERNAL and ONE EXTERNAL
What is the durbin watson statistic : What is the Durbin Watson Statistic. How is it calculated, and what is its significance in Statistics?
Write a function that recursively reverses a string : Write a function that recursively reverses a string. The function will have a single parameter of type string.
Illustrate the effectiveness of the organization : Research at least five peer-reviewed articles from academic journals, government sources, or research institutions (e.g. Rand) to detail the police organization
Display current will display the first and last name : A Simple program is needed to keep track phone numbers. This program should allow you to enter a contact name and find that contact's phone number.
Identify the claim and state h0 and ha : (a) Identify the claim and state H0 and Ha. Which is the correct claim? below? What are H0 and Ha??
Identify the ethical dilemma raised by the facts : Identify the ethical dilemma raised by the facts and explain what the ethical dilemma is. What makes this dilemma ethical? What ethics does this dilemma.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Construct a causal loop diagram for a process

Construct a causal loop diagram for a process with the following behaviors. A company has a Desired Staff Level.

  Write a program that swaps the elements of an array pairwise

Write a program that swaps the elements of an array pairwise. Start from the left of the array, take 2 elements at a time and swap the two elements. Continue in this fashion until you reach the end of the array.

  Analyze the general transition of us health laws based on

1.from the scenario differentiate between the concepts of criminal law antitrust and health care as they apply to

  Include a cover page containing the title of the

you have been tasked with building a payroll program for a large organization with offices spread across the united

  How the impact of computer crime is quantified

Elaborate on how the impact of computer crime is quantified. Please share at least two examples. Include at least four (4) reputable sources.

  What is the smallest accurate big-oh notation for finding

What is the smallest accurate big-Oh notation for finding an optimal tour for a travelling sales person problem on a graph with with V vertices?

  How can you sort array of country objects by increasing area

How can you sort an array of Country objects by increasing area? Can you use the Arrays.sort method to sort an array of String objects?

  Declaring a variable using the public, friend, or private

In visual basic.NET, what makes up a component? What are the advantages of components? In addition, what are the types of class data and how do you decide which is appropriate? describe the difference between declaring a variable using the keyword..

  Explain the role of cyber-security privacy controls

Create an overview of the HIPAA Security Rule and Privacy Rule. Explain the role of cyber-security privacy controls in the review of system processes.

  Benefit of ethical hacking

Describe what you consider is the main benefit of the ethical hacking be sure to involve what is the role of an ethical hacker.

  What should be included in a package diagram

What should be included in a package diagram with dependency relationships? Create that package diagram.

  Questioncreate a white paper based on knowledge listed

questioncreate a white paper based on knowledge listed below. please be sure to contain any security concerns. include

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd