Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Basic Functions And Subroutines (C++)
SUBMITTED BY:
yppah
DATE:
Jan. 24, 2016, 5:33 a.m.
FORMAT:
Text only
SIZE:
496 Bytes
Raw
Download
Tweet
HITS:
4771
Go to comments
Report
#include
using namespace std;
double harmean(int x,int y);
int main()
{
int a, b;
cout<<"Please, enter two integers: ";
while (!(cin>>a)||!(cin>>b)||a==0||b==0)
{
cin.clear();
while(cin.get()!='\n')
continue;
cout<<"\nPlease, enter two integers: ";
}
cout<<"\nThe harmonic mean of "<<a<<" and "<<b<<" = "<<harmean(a,b);
cout<<"\n\n";
return 0;
}
double harmean(int x, int y)
{
double hm=0.0;
hm=2.0*x*y/(x+y);
return hm;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus