Last active
December 4, 2019 21:50
-
-
Save oykelrae/37ec5c3c4ba219507da9b15fe33207e4 to your computer and use it in GitHub Desktop.
<math.h> The area of a triangle given 3 sides
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, s3, p, area; | |
printf("Enter the lengths of 3 sides of a triangle: "); | |
scanf("%lf %lf %lf", &s1, &s2, &s3); | |
p = (s1 + s2 + s3) / 2; | |
area = sqrt(p*(p-s1)*(p-s2)*(p-s3)); | |
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 3 sides of a triangle: 8 11 5 | |
The area of the triangle is 18.33 | |
Program ended with exit code: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment