/* * angle.c * * * Created by xwu3 on 3/1/09. * Copyright 2009 University of Iowa. All rights reserved. * */ #include #include double Square(double x); int main (void) { double a, b, c; double angle; double degree; printf( "Enter three edges of the triangle: "); scanf( "%lf%lf%lf", &a, &b, &c); if ((a + b > c) && (a + c > b) && (b + c > a)) { /* a, b and c form a triangle */ angle = acos((Square(a) + Square(b) - Square(c))/(2*a*b)); degree =angle * 180 / M_PI; printf( "The angle is %.2f\n", degree); } else { /* a, b and c do NOT form a triangle */ printf( "The input three edges cannot form a triangle.\n"); } return 0; } double Square(double x) { double s2; s2 = x * x; return s2; }