//Herons.C // (c) Burt Rosenberg 1996 // This program introduces the float object, and // compiling and linking with the math library #include #include void main() { float a, b, c ; // three sides of the triangle float s, areaSquared ; cout << "Enter a: " ; cin >> a ; cout << "Enter b: " ; cin >> b ; cout << "Enter c: " ; cin >> c ; // caculate the semi-perimeter s = ( a + b + c ) / 2.0 ; areaSquared = s * (s-a) * (s-b) * (s-c) ; if ( areaSquared <= 0.0 ) { cout << "This triangle is impossible." ; } else { cout << "The area of this triangle is " << sqrt(areaSquared) ; } cout << endl ; }