Programming Exercises

1:Write a program that repeatedly asks you to enter pairs of numbers until at least one of the pair is zero. For each pair, the program should use a function to calculate the harmonic mean of the numbers. The function should return the answer to main(), which reports the result. The harmonic mean of the numbers is the inverse of the average of the inverses and can be calculated as follows:

harmonic mean = 2.0 * x * y / (x + y)

2:Write a program that asks you to enter up to ten golf scores, which are to be stored in an array. You should provide a means for the user to terminate input prior to entering ten scores. The program should display all the scores on one line and report the average score. Handle input, display, and ...

Get C++ Primer Plus, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.