67.2k views
0 votes
4. (Hypotenuse Calculations) Define a function called hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. The function should take two arguments of type double and return the hypotenuse as a double. Test your program with the side values specified in Fig

User Poogy
by
5.5k points

1 Answer

3 votes
Hypotenuse = sqrt(a^2 + b^2)

A program in C:
double hypotenuse(int a, int b) {
return sqrt(pow(a, 2) + pow(b, 2));
}
User Kay Tsar
by
5.6k points