#include <stdio.h>
#include <math.h>
typedef struct POINT {
double x, y;
} POINT;
double sqr (double x);
double DIST(const POINT *a, const POINT *b);
double AREA(double a, double b, double c);
int main() {
POINT p, q, r;
double d1, d2, d3, area;
printf("Please enter the coordinates of the triangle vertices and press ENTER.\n");
scanf("%lf %lf %lf %lf %lf %lf", &p.x, &p.y, &q.x, &q.y, &r.x, &r.y);
d1=DIST(&p,&q);
d2=DIST(&p,&r);
d3=DIST(&q,&r);
area=AREA(d1, d2, d3);
area=AREA(d1, d2, d3);
printf("The area of the triangle is %lf\n", area);
return(0);
}
double sqr (double x) {
return(x*x);
}
double DIST(const POINT *a, const POINT *b) {
return( sqrt( sqr(a->x - b->x) + sqr(a->y - b->y) ) );
}
double AREA(double a, double b, double c) {
double p=(a+b+c)/2.0;
double ar=sqrt(p*(p-a)*(p-b)*(p-c));
return(ar);
}