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

Write a program to calculate the hypotenuse of a right angledtriangle by inputti

ID: 3617477 • Letter: W

Question

Write a program to calculate the hypotenuse of a right angledtriangle by inputting the length of other 2 sides from the keyboardusing the following equation:-

sideC = sqrt( sideA * sideA+ sideB * sideB)

Where sideA: the length of a side facing angle A

           siedB: the length of a side facing angle B

           sideC: the length of a side facing the 90 degrees

                     which is the hypotenuse of a right angled triangle


sqrt is a built in function with the following functionprototype. For reference, search the web for this functionprototype.

double sqrt (double x);

Therefore to write this program

(a) declare double sumSquare = 0.0 ;

(b) declare double sideA=0.0, sideB=0.0, sideC=0.0;

(c) Read in the value for sideA and sideB from the keyboardusing

     interactive approach.

(d) calculate the sum square using this formula:-

      sumSquare = (sideA * sideA + sideB * sideB);

(e) calculate sideC using the function sqrt

      sideC = sqrt(x);

(f) print the value of sideA, sideB and sideC.

You have to run the program with 2 sets of values:-

(1)          sideA =3, sideB = 4

(2)         Pick anotherset of values yourself for testing.

You are dealing with the math.h header file. Remember the“-lm” used to compile your program.

$ gcc side.c -o side.out -lm

$ side.out

Explanation / Answer

please rate - thanks #include #include int main() {double sumSquare = 0.0 ; double sideA=0.0, sideB=0.0, sideC=0.0; printf("Enter value of the 1st side"); scanf("%lf",&sideA); printf("Enter value of the 2nd side"); scanf("%lf",&sideB); sumSquare=sideA*sideA+sideB*sideB; sideC=sqrt(sumSquare); printf("Side 1=%f Side 2=%f Hypotenuse =%f ",sideA,sideB,sideC); return 0; }
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