Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- double hmean (double a, double b);
- int main ()
- {
- double x, y, z;
- cout << "Enter two numbers:";
- while (cin >> x >> y)
- {
- z = hmean (x, y);
- cout << "Harmonic mean of " << x << " and " << y << " is " << z << "\n";
- cout << "Enter next set of numbers <q to quit>:";
- }
- cout << "Bye!\n";
- return 0;
- }
- double hmean ( double a, double b)
- {
- if (a == -b)
- {
- cout << "untenable arguments to hmean ()\n";
- abort ();
- }
- return 2.0 * a * b / (a + b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement