Computers and Technology
Computers and Technology, 31.01.2022 19:10, dayanaram

4. Write a program of two functions. The main function asks the user to enter 5 numbers and stores them in an array. Then the main function should pass the array to the second function calcAvg(). The function calcAvg() will calculate the average of the array and return the result to the main function. Finally, the main function will display the average on the screen. (30%) You may assume that the user only enters numbers, not letters or symbols. Therefore there is no input failure.
Hint: (1) The calcAvg() function should take 2 parameters, one is for the array, the other is for the size of the array.
(2) Use a for loop to compute the sum, and divide it by the size to get the average.
If you prefer, you can read the 5 numbers from a file, and write the average to another file.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:30, melissalopez12
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
image
Computers and Technology, 23.06.2019 06:10, erick7123
The head restraint should be adjusted so that it reaches a. the top of your ears b. the base of your skull c. the top of the head
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, daelinrobinson
If you're using an existing powerpoint presentation that will receive new slides based on a word outline, select the a. slide that will appear after the new slides. b. first slide in the presentation. c. slide that will appear before the new slides. d. last slide in the presentation.
Answers: 2
image
Computers and Technology, 23.06.2019 14:30, qveenvslayin
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
Do you know the correct answer?
4. Write a program of two functions. The main function asks the user to enter 5 numbers and stores t...

Questions in other subjects: