Contact Learn C
Copy

Program 381: Find Angles of Triangle for given lengths of sides

Program 381: Find Angles of Triangle for given lengths of sides
 
#include<stdio.h>
#include<math.h>
main()
{
 int a,b,c;
 double A,B,C;
 const double PI =  3.1415926;
 printf("Enter length of a\n");
 scanf("%d",&a);
 printf("Enter length of b\n");
 scanf("%d",&b);
 printf("Enter length of c\n");
 scanf("%d",&c);
 /*
 Reference:---
    a² = b² + c² - 2bc cosA
       b² = a² + c² - 2ac cosB
       c² = b² + a² - 2ba cosC
    
 */
 A=acos((-pow(a,2)+pow(b,2)+pow(c,2))/(2*b*c));
 B=acos((pow(a,2)-pow(b,2)+pow(c,2))/(2*c*a));
 C=acos((pow(a,2)+pow(b,2)-pow(c,2))/(2*a*b));
 A*=180/PI;
 B*=180/PI;
 C*=180/PI;
 printf("Angle of A=%lf\n",A);
 printf("Angle of B=%lf\n",B);
 printf("Angle of C=%lf\n",C);

}
Explanation:
 //Coming Soon


Output:
Find Angles of Triangle for given lengths of sides


Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide