Last active
December 4, 2019 21:50
-
-
Save oykelrae/9f4033a5dda1aed1a3ca090f535a83cc to your computer and use it in GitHub Desktop.
<math.h> The area of a triangle given 2 sides and the angle between them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
int main() { | |
double s1, s2, angle, area; | |
printf("Enter the lengths of two sides of a triangle: "); | |
scanf("%lf %lf", &s1, &s2); | |
printf("Enter the angle between them (in degrees): "); | |
scanf("%lf", &angle); | |
area = (s1 * s2 * sin((3.141593 / 180) * angle)) / 2; | |
printf("The area of the triangle is %.2lf\n", area); | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enter the lengths of two sides of a triangle: 7 5 | |
Enter the angle between them (in degrees): 30 | |
The area of the triangle is 8.75 | |
Program ended with exit code: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment