I have to write a program that calculates the perimeter, semiperimeter, area and centroid of a triangle using coordinates input by user. Some of the requirements for the program are: "write 2 functions which have 6 parameters (x and y values of each of the points) and compute the area and perimeter of triangle. write 2 functions which have 3 parameters and compute the x and y values of the centroid." I have written a function that computes the side of a triangle which is:
int main(void)
{
double point1, point2, point3, point4, point5, point6;
printf("Enter coordinates of point A (x y):");
scanf("%lf%lf", &point1, &point2);
printf("Enter coordinates of point B (x y):");
scanf("%lf%lf", &point3, &point4);
printf("Enter coordinates of point C (x y):");
scanf("%lf%lf", &point5, &point6);
My first question is: How do I use the values returned in the distance function in another function to determine perimeter. And after that, use the values from the perimeter function to determine area in the area function.
My second question is: How do print the coordinates the user input in parentheses? For example user inputs 3,4 as coordiantes for point A. My output has to be "Point A = (3.000, 4.000). I forgot to mention that this program has to be written in C and not C++
Thanks for your advice. I won't be able to use the STRUCT feature/function because we have not learned that in class yet. We have to use functions. Do you know how I would use the values from my distance function in another function to calculate the perimeter?? Again, thanks for all your help.