So my program here is suppose to take 3 values and store it in the variables Ax,Ay etc... but for some reason it keeps returning 0.00 for the area and from what I see all of this code should return a proper area, it applies the distance formula and heron's formula for area
#include <stdio.h>
#include <math.h>
int main(void) {
float Ax,Ay,Bx,By,Cx,Cy,A,B,C,side,area;
printf("hello inPut x,y coords");
printf("input 3 numbers for your x coordinates");
scanf("%f%f%f",&Ax,&Bx,&Cx );
printf("input 3 numbers for your y coordinates");
scanf("%f%f%f",&Ay,&By,&Cy);
A=sqrt(((Bx-Ax)*(Bx-Ax))+((By-Ay)*(By-Ay)));
B=sqrt(((Cx-Bx)*(Cx-Bx))+((Cy-By)*(Cy-By)));
C=sqrt(((Ax-Cx)*(Ax-Cx))+((Ay-Cy)*(Ay-Cy)));
side=((A+B+C)/2);
area=sqrt(side*(side-A)*(side-B)*(side-C));
printf("n AREA OF TRIANGLE IS %f",area);
}
The Pseudo-Code of what it's suppose to do is this:
Take 3 numbers like
5,7,8
These first three numbers are now stored in Ax,Bx,Cx (Ax=5,Bx=7,Cx=8)
Take 3 more numberss for the y coordinate (1,2,3)
Store numbers in Ay By Cy (Ay =1, By=2, Cy=3)
take these values and calculate the distance between them by using this formula:
sqrt((Bx-Ax)^2+(By-Ay)^2)
repeat this 2 more time for the other numbers
now it calculates the perimeter of the triangle, and halves it , then inputs it into the heron formula to get the area.
Ideally these values should give an area > 0.