Language C
Description Write a program that prompts the user to enter the tree points (x1, y1), (x2, y2), and (x3, y3) of a triangle and displays its area.
The formula for computing the area of a triangle is:
s = (side1 + side2 + side3) / 2
area = sqrt(s * (s - side1) * (s - side2) * (s - side3))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main (void)
{
    float area, s, side1, side2, side3;
    float x1, x2, x3, y1, y2;
    float y3;
    printf ("Enter the value of x1: ");
    scanf ("%f", &x1);
    (void) getchar ();
    printf ("Enter the value of x2: ");
    scanf ("%f", &x2);
    (void) getchar ();
    printf ("Enter the value of x3: ");
    scanf ("%f", &x3);
    (void) getchar ();
    printf ("Enter the value of y1: ");
    scanf ("%f", &y1);
    (void) getchar ();
    printf ("Enter the value of y2: ");
    scanf ("%f", &y2);
    (void) getchar ();
    printf ("Enter the value of y3: ");
    scanf ("%f", &y3);
    (void) getchar ();
    side1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    side2=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    side3=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    s=(side1+side2+side3)/2;
    area=sqrt(s*(s-side1)*(s-side2)*(s-side3));
    printf ("Value of area: %g\n", area);
    printf ("Value of s: %g\n", s);
    printf ("Value of side1: %g\n", side1);
    printf ("Value of side2: %g\n", side2);
    printf ("Value of side3: %g\n", side3);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}