A right triangle is a triangle that has a 90-degree angle. The side opposite the
ID: 3634437 • Letter: A
Question
A right triangle is a triangle that has a 90-degree angle. The side opposite the 90-degree angle iscalled the hypotenuse and the sides adjacent to the 90-degree angle are called legs. Consider a right
triangle with sides a; b; c, where a; b are the legs and c is the hypotenuse. The following equation
holds
c2 = a2 + b2:
Let be the angle (in degree) between a; c, and be the angle (in degree) between b; c. Then we
have
=
180
arctan(b=a); =
180
arctan(a=b); + = 90:
Write a program triangle.c that prompts the user for the double-precision1 legs of a right triangle
and prints the hypotenuse and the smallest angle (in degree) of that triangle with 1-decimal point
precision.
Include a function void Compute(double *cp, double *anglep, double a, double b) that
computes the hypotenuse and the smallest angle of the right triangle with legs a; b, and stores
them respectively in the variables pointed by cp and anglep.
Sample runs:
(~)$ a.out
Legs: 3.0 4.0
Hypotenuse: 5.0
Smallest angle: 36.9 degree
(~)$ a.out
Legs: 5 10
Hypotenuse: 11.2
Smallest angle: 26.6 degree
(~)$ a.out
Legs: 2.5 2.5
Hypotenuse: 3.5
Smallest angle: 45.0 degree
(~)$