112k views
5 votes
If a right triangle has sides of length a, b and c and if c is the largest, then it is called the "hypotenuse" and its length is the square root of the sum of the squares of the lengths of the shorter sides (a and b). assume that variables a and b have been declared as doubles and that a and bcontain the lengths of the shorter sides of a right triangle: write an expression for the length of the hypotenuse.

1 Answer

4 votes

Assuming this is for a programming language like c++, then the expression might look like

c = sqrt(a*a + b*b)

or you can use the pow function (short for power function)

c = sqrt( pow(a,2) + pow(b,2) )

writing "pow(a,2)" means "a^2"; similarly for b as well.

User Younes El Ouarti
by
8.6k points