
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![**Using C++ write code for the following and call from a main function**
(a) A function that via its parameter list, receives a one-dimensional array of an arbitrary (i.e. [ ]) size, of type double and populates it with random positive doubles only in the range 0.0 and 9.0. Show how to pass array size also in parameter list to this function.
(b) A function that via its parameter list receives a one-dimensional array of arbitrary size of type double and returns the average of the elements in the array via a double return variable. Enforce that the function may not change the array or size parameter data passed to it in any way.
(c) A function that receives via its parameter list a one-dimensional array of arbitrary size, containing type double and prints its elements. Enforce that the function may not change the array or size parameter data passed to it in any way.
(d) Write a main function in which you show how to call the functions in parts (a), (b), and (c) above.
You may only declare one doubles array of some size of your choosing in the main function at the beginning, which you must then use for parts (a), (b) and (c) to populate, calculate the average of, and then print.](https://content.bartleby.com/qna-images/question/ada2d32d-a176-418f-aab9-c8e9e8a4e1ba/53b2b739-4c06-424d-8edb-7efb381d1eb0/6ia4k3r_thumbnail.png)
Transcribed Image Text:**Using C++ write code for the following and call from a main function**
(a) A function that via its parameter list, receives a one-dimensional array of an arbitrary (i.e. [ ]) size, of type double and populates it with random positive doubles only in the range 0.0 and 9.0. Show how to pass array size also in parameter list to this function.
(b) A function that via its parameter list receives a one-dimensional array of arbitrary size of type double and returns the average of the elements in the array via a double return variable. Enforce that the function may not change the array or size parameter data passed to it in any way.
(c) A function that receives via its parameter list a one-dimensional array of arbitrary size, containing type double and prints its elements. Enforce that the function may not change the array or size parameter data passed to it in any way.
(d) Write a main function in which you show how to call the functions in parts (a), (b), and (c) above.
You may only declare one doubles array of some size of your choosing in the main function at the beginning, which you must then use for parts (a), (b) and (c) to populate, calculate the average of, and then print.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Similar questions
- Use C++arrow_forwardHelp with c++...paste indented code plzz Write a function definition for a function named removeEnds to do the following: a. Accept an array A and the size of array A as parameters. b. Return a new dynamic array B which contains all but the first and last elements of the array A. c. Solution must use pointer arithmetic instead of [] notation. ExampleIf array A is 31,7,89,34,2, array B would be 7,89,34arrow_forwardWrite a program to solve quadratic equations for real roots. No need to use imaginary numbers. ax^2 +bx +c= 0 Requirements:-Define an array of type double with size 3 in main() to store the 3 coefficients.-Read the 3 coefficients from user input.-Create the function prototype and definition for the function getRootCount(discriminant, coefficients) Parameters: discriminant: output to be calculated by the function coefficients: input array of 3 coefficients Return: number of roots: 0, 1, or 2 -Create the function prototype and definition for a function to determine the numbers of roots: getRootCount(discriminant, coefficients); Parameters: discriminant: output value to be calculated by the function (reference parameter) coefficients: input array of 3 coefficients Return: number of roots: 0, 1, or 2 (int) -Create the function prototype and definition for a function to solve equations and get the root(s): solveEquation(discriminant,…arrow_forward
- Write a function using Java Function Name: winInRowParameters: board: 2D integer array, row: integer, piece: integerReturn: booleanAssume board is valid 2D int array, row is valid index in the board, piece is X==1/O==2Look at indicated row at given index in board. If that row has at least 3 consecutive entries withgiven type of piece (X/O) (3 in a row XXX, OOO), then return true, otherwise false.arrow_forwardIn python find_substring("It was the best of times, it was the worst of times", "i") [20, 26, 47] >>> find_substring('Episode III: Revenge of the Sith', "e ") [6, 19, 26] >>> find_substring("bobbobob", "bob") [0, 3, 5]arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY