Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define a function called hypotenuse that calculates the length of the hypotenuse

ID: 3635841 • Letter: D

Question

Define a function called hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. use this function in a program to determine the length of the hypotenuse for each of the following triangles. The function should take two argument of the type float and return the hypotenuse as a float. test program with side values specified in Figure 1.
Triangle Side 1 Side 2 Hypotenuse
1 3.0 4.0 5.0
2 5.0 12.0 13.0
3 8.0 15.0 17.0
Figure 1 : Sample triangle side values.

Explanation / Answer

please rate - thanks

in C, with test program

the 2 red lines are non standard. if you get an error on them, just remove them. some compilers need them

#include<stdio.h>
#include<math.h>
#include <conio.h>
float hypotenuse(float,float);
main()
{int i;
float a,b;
for(i=1;i<=3;i++)
    {printf("enter side 1: ");
    scanf("%f",&a);
    printf("enter side 2: ");
    scanf("%f",&b);
    printf("s1de 1: %.1f side 2: %.1f hypotenuse: %.1f ",a,b,hypotenuse(a,b));
   }
getch();
}
float hypotenuse(float a,float b)
{return sqrt(a*a+b*b);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote