/* * Example of using C library functions * * Compute the length of the third side using the formula * a^2 = b^2 + c^2 - 2*b*c*cos(alpha) * where b and c are the lengths of two sides of a triangle, and * alpha is the angle between them in degree * Hanly and Koffman, Example 3.3, page 110 * */ #include #include #define PI 3.14159 int main(void) { double a, b, c, alpha; printf("Input the lengths of two sides b and c > ",b,c); scanf("%lf%lf",&b,&c); printf("and the angle between them in degree >", &alpha); scanf("%lf",&alpha); /* compute the length of third side */ a = sqrt(pow(b,2) + pow(c,2) - 2 * b * c * cos(alpha * PI / 180.0)); printf("Length of the third side a = %.2f\n",a); return 0; }