Input Three Sides Of A Triangle & Compute The Area Of The Triangle

Input Three Sides Of A Triangle & Compute The Area Of The Triangle

Code
// Input three sides of a triangle and compute the area of a triangle.

#include <stdio.h>
#include <math.h>
int main()
{
    float a, b, c, s, area;
    printf("Enter The Three Sides Of The Triangle: ");
    scanf("%f%f%f", &a, &b, &c);

    s = (a + b + c) / 2;
    area = sqrt(s * (s - a) * (s - b) * (s - c));
    printf("Area Of The Triangle Is: %.2f", area);
    return 0;
}
Output
Enter The Three Sides Of The Triangle: 4 6 8
Area Of The Triangle Is: 11.62

Post a Comment