Array elements and returns the sum

Assignment Help Basic Computer Science
Reference no: EM132494177

Write the following functions. Each takes an array of ints and the array length. The return types differ. You should also create a temporary main() function for testing purposes. Use the array initialisation notation to create test arrays. (Later we'll replace this with another main() that takes user input via command-line parameters.)

(a) sum() - adds up all the array elements and returns the sum, an int. (For an array containing {5, 10, 15}, sum() should return 30.)

(b) max() - returns the index of the largest element in the array. (For an array containing {10, 5, 1}, max() should return 0. For the array {3, 15, 6, 500, 9} it should return 3).

(c) reverse() - reverses the order of the array elements. It doesn't return anything. (For an array containing {1, 2, 3, 4}, reverse() should change it to {4, 3, 2, 1}.)

Reference no: EM132494177

Questions Cloud

Option to implement it on windows server : An organization is in the process of migrating to a newer enterprise resource planning application. There is an option to implement it on Windows Server 2008
What amount can be awarded each year : What amount can be awarded each year, starting in a year, if the fund earns 7% compounded monthly? Travis makes a donation of $21000 to a local parks
What will the impact be on the business environment : Lower rates in response to the 2008 recession. What is the economic significance of this change? What will the impact be on the business environment?
Class deals with computer architecture : This class deals with computer architecture topics like logic circuits with gates and memory (byte-addressable and word-addressable).
Array elements and returns the sum : Write the following functions. Each takes an array of ints and the array length. The return types differ. You should also create a temporary
What was the value of the home theatre set at the time : The whole time interval (even when you don't have any payments). What was the value of the home theatre set at the time of purchase?
What is the maximum amount that can be withdrawn : The entire 25 year period is 4.3% compounded quarterly, then what is the maximum amount that can be withdrawn at the start of each quarter?
Chart for disasters caused by major forces of nature : The question wants me to comparison chart for disasters caused by major forces of nature (hurricane, tornado, earthquake, flood, and fire).
How much is jimmys rrsp worth : The beginning of every quarter for 35 years. Assume the interest rate is 7% compounded monthly. How much is Jimmy's RRSP worth after 35 years?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  How the balance between these two sets of data varies

Report on the statistical information that is being gathered by taxis and the passenger source; also on taxi idle time and missed pickups. Experiment with different numbers of taxis to see how the balance between these two sets of data varies.

  Study evidence for defence in law firm

You are engaged by law firm to study evidence for the defence. You uncover evidence that doesn't help your client's case but was not discovered by the prosecution.

  How can two cubical

how can two cubical (six sided) dice be labelled using numbers {0,1,2,3,4,5,6} so that when the two dice are thrown, the sum has a uniform probability distribution over the integers ( 1,2...12}.The same number can repeat more than once on a face of e..

  Draw context diagram and the level 0 expansion

Draw Context Diagram and the Level 0 Expansion for the following problem The pharmacy at Mercy Hospital fills medical prescriptions for all hospital patients and distributes these medications to the nurse stations responsible for the patients' care. ..

  When do you use perl for programming

Explain Perl. When do you use Perl for programming? What are the advantages of programming in Perl?

  How important is ordering in v-blast

We may call such a system V-BLAST with no ordering. How does it compare with the V-BLAST (ZF nulling) curve in Figure 9.10? How important is ordering in V-BLAST?

  Net present value of cash flow analysis

In one hundred word describe What is the acceptance or rejection criteria when using the net present value of cash flow analysis?

  Suppose the minimum wage were increased sharply

Suppose the minimum wage were increased sharply. How would this affect the equilibrium prices level and output level in the model of aggregate demand

  Research examples of security policies

Use the Internet to research examples of security policies. Choose one and develop a general security policy for a fictitious law firm.

  Write a method that does a reverse lookup

Write a program that stores names and phone numbers from a text file in a dictionary, with the name being the key. Write a method that does a reverse lookup, that is, finds a name given a phone number. Write a Windows application to test your impl..

  Policies implemented by the reagan administration

What was the state of the economy prior to Reagan implementing supply side economics? What were some of the policies implemented by the Reagan administration?

  What sql statement should you use

You want to create a save point named svpt_Section2. What SQL statement should you use?

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