/* * Program to compute hypotenuse of a right triangle (sqrt(a*a + b*b)). * * Input: floating-point numbers a, b. * * Output: sqrt(a*a + b*b) */ #include #include /* Computes hypotenuse of right triangle with sides a and b, and returns it */ float hypotenuse(float a, float b) { /* all of these work */ return sqrt(a*a + b*b); /* return sqrt(pow(a, 2) + pow(b, 2)); */ /* return pow((pow(a, 2) + pow(b, 2)), 0.5); */ } /* Main program */ int main(void) { float input1; float input2; printf("enter two sides of a right triangle:\n"); scanf("%f", &input1); scanf("%f", &input2); printf("hypotenuse for sides %f and %f is %f\n", input1, input2, hypotenuse(input1, input2)); return 0; }