(Hypotenuse Calculations) Define a function hypotenuse that calculates the hypotenuse of a right triangle when the other two sides are given. The function should take two double arguments and return the hypotenuse as a double. Use this function in a program to determine the hypotenuse for each of the triangles shown below.



What will be an ideal response?


```
// Calculate hypotenuse value for a right triangle
// given values for two sides.
#include
#include
#include
using namespace std;

double hypotenuse( double, double ); // function prototype

int main()
{
double side1; // value for first side
double side2; // value for second side

cout << fixed; // set floating-point number format

// loop 3 times
for ( int i = 1; i <= 3; i++ )
{
<< "\nEnter 2 sides of right triangle: ";
cin >> side1 >> side2;

// calculate and display hypotenuse value
cout << "Hypotenuse: " << setprecision( 1 )
<< hypotenuse( side1, side2 ) << endl;
} // end for
} // end main

// hypotenuse calculates value of hypotenuse of
// a right triangle given two side values
double hypotenuse( double s1, double s2 )
{
return sqrt( s1 * s1 + s2 * s2 );
} // end function hypotenuse
```

Computer Science & Information Technology

You might also like to view...

The ________ statement executes one block of statements if a test condition is true, and another block if the condition is false.

A) if B) if/else C) if/else if D) switch E) trailing else

Computer Science & Information Technology

A top-level domain is the highest category in the Internet naming system.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The navigation bars in the master and detail pages include First Page, Previous Page, Next Page, and ____ buttons.

A. Last Page B. End Page C. Middle Page D. Newest Page

Computer Science & Information Technology

The address operator in C is ____.

A. & B. * C. -> D. .

Computer Science & Information Technology