Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that takes an array of 10 integer numbers and calculates the average and the sum of the array using two different functions

image text in transcribed

Write a program that takes an array of 10 integer numbers and calculates the average and the sum of the array using two different functions a) (5 pts) Declare and write a function called calcavg. Returns a double, passes the array. Calcavg adds the 10 elements of the array and divides by 10 to return the average Assume there are always 10 elements. Calcavg does not display any result. b) (5 pts) Declare and write a function called calcsum. Returns void. Passes the array and an integer variable by reference. Sums the 10 elements of the array and sets the summation to the variable passed by reference. Calcsum does not display any result. (10 pts). Write a program that has the appropriate headers and variable declarations. program should create an integer array, nums of 10 elements containing the numbers 1,2,3,4,5, 6,7,8,9,10. Please add several comments throughout your program and functions. c) The d) (5 pts). The main program should display the elements of the array using a for loop. The display should look exactly as shown below. Use field width manipulators. e) (5 pts). Call the two functions and display the average and sum of the elements of the array using statements in the main function. The terminal window should look exactly as shown. The elements of nums are: 1 2 3 45 67 8 9 10 The average of nums is 5.50 The sum of nums is 55 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

=+7. Compare Walmarts new and old logos:

Answered: 1 week ago

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago

Question

=+ What is the role of government in bargaining?

Answered: 1 week ago

Question

=+ Who is the negotiation partner at company level?

Answered: 1 week ago

Question

=+Which associations exist?

Answered: 1 week ago