#include #include using namespace std; float pythag( float a, float b ) // It is assumed that a and b are nonnegative { const float SQRT2 = 1.41421356f; float c; if ( a == b ) c = SQRT2 * a; else if ( a > b ) c = a * sqrt( 1.0f + pow( (b/a), 2 ) ); else c = b * sqrt( pow( (a/b), 2 ) + 1.0f ); return( c ); } int main() { const float MAX_HYPOT = 1000.0; float a, b, c; cout << "Enter a and b separated by a space.\n"; cin >> a >> b; cout << "\n"; cout.precision(7); if ( ( a > 0.0 ) && ( b > 0.0 ) ) { c = pythag( a, b ); cout << "The hypotenuse has length " << c << endl; if ( c > MAX_HYPOT ) cout << "Wow! That's one big triangle." << endl; } else cout << "These are not side lengths of a triangle." << endl; cout << "\n\n"; system( "PAUSE" ); return( 0 ); }