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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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