Write a function addup that adds up all the numbers

Assignment Help Computer Engineering
Reference no: EM132164440

Using C++

Do not make use of any variables in your answers to this question.

Use recursive functions to cause repetition when needed. All numbers will be ints. No Loops

Part A. Write a function addup(x, y) that adds up all the numbers between x and y (inclusive), and returns their sum as its result.

e.g.

const int a = addup(2, 5);

defines a to be 14 because 2+3+4+5 = 14.

Part B. Write a function addup_arr(R, x, y), where R is an array of ints. It should add up all the numbers from position x to position y in the array, and return their sum as its result.

e.g.

const int b[] = { 7, 3, 1, 6, 14, 2, 9, 5 };

cout << addup_arr(b, 2, 5);

prints 23 because 1+6+14+2 = 23.

Part C. Write another function sum_arr(R, n), where R is an array of ints, and n is the size of that array. It should add up all the numbers in the array and return the result.

e.g.

cout << sum_arr(b, 8)

prints 47 because 7+3+1+6+14+2+9+5 = 47

Part D. Write a function max_arr(R, n), where R and n are as described in part c. It should find the largest number in the array, and return that maximum as its result. Hint - use an extra parameter to remember the biggest number encountered so far.

e.g. max_arr(b, 8) is 14

Reference no: EM132164440

Questions Cloud

Read and use files grocery hardware store chores : Add as many items as necessary Delete as many items as necessary Move between lists as often as my little heart desires.
Geometric distribution assume the probability : Using geometric distribution assume the probability that you will make a sale on any given telephone call is 0.19. Find the probability that you
Information about the random variables : We have the following information about the random variables X and Y
Assuming a population standard deviation transaction prices : An online used car company sells second-hand cars. For 30 randomly selected transactions, the mean price is 2200 dollars.
Write a function addup that adds up all the numbers : Write a function addup(x, y) that adds up all the numbers between x and y (inclusive), and returns their sum as its result.
Illustrate the distributions involved : a) Use the fo ur steps of hypothesis testing b) Illustrate the distributions involved
How does central limit theorem apply to this problem : In a random sample of 36 people, find the probability that the average amount spent is more than $61.50. How does central limit theorem apply to this problem?
Describe the frame status quo as it relates to your topic : Topic: "Molecular Biology". Your presentation must: Describe the frame's status quo as it relates to your topic. Argue how your final project intervenes
Write a function that will return a true : Write a function that will return a true, if the ransom note can be constructed from the words in the magazines, otherwise it will return a false.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Discuss global standards by cyberattack technologies

Discuss the challenges posed to the development of global standards by cyberattack technologies

  What is the difference between a password and a passphrase

What is the difference between a password and a passphrase? Why is it necessary to have a passphrase? What does this command do? ssh jupiter date \> .date.

  Determine the best manner to encode each character

Suppose a document contains 22 A, 12 B, 24 C, 6 D, 27 E, 9 F. Determine the best manner to encode each character with the least number of bits by a greedy approach.

  Designing program

Write down a Program that lets the user enter an amount as a float value representing a total in the dollars and cents.

  What will be the exercise ratio of men and women

What will be the exercise ratio of men and women? Results indicated that women averaged 2 hours per week and men averaged 1.25 hour per week.

  What is the expected value of the jaccard similarity

Suppose s1 and s2 are randomly selected subsets from a universal set with n items. What is the expected value of the Jaccard similarity J(s1, s2)?

  Find a lower interest rate

how much does it lower your payment if you shop around and find a lower interest rate? How much could you lower the payment by having a bigger down payment? What happens if you extend the term of the loan.

  What are the essential ingredients of a symmetric cipher

What are the essential ingredients of a symmetric cipher? How many keys are required for two people to communicate via a symmetric cipher?

  Make a letter applying for the job and write a resume

Your letter has to address the details in the ad. So, if the ad says the successful candidate will need to speak Spanish, you should say whether or not you can speak Spanish in the letter.

  How can the security vulnerabilities be handled

How can the security vulnerabilities common with wireless networking be handled to mitigate the risks?

  Describe the password-based and role-based authentication

What are the differences between password-based authentication and role-based authentication? What are their advantages and disadvantages?

  Create a recursive java program that will traverse the array

Create a recursive Java program that will traverse the array looking for a path from the upper left corner to the lower right.

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