Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE ARRAY and POINTER FOR THE Vertices and Lengths!) To Create a C script that w

ID: 3605324 • Letter: U

Question

USE ARRAY and POINTER FOR THE Vertices and Lengths!) To Create a C script that will take user input of 3 vertices to calculate the area of a triangle by using Heron' Formula. You will need the "pow" function in "math.h" header file. Your output should have the format of -With the given vertices (Display Vertices) the area of the triangle is (The result.) Heron's Formula S= A+B+C 2 Area S(S -AXS -B)(S -C) Conditions: All Vertices have to be included in a single ARRAY and its pointer! Lengths A, B, and C have to be included in a single ARRAY and its pointer! All the computation has to be done by using POINTER ONLY! · .

Explanation / Answer

#include<stdio.h>
#include<math.h>

// function to calculate area
float Area(float *vertices)
{
//to calculate s
float s = (vertices[0]+vertices[1]+vertices[2])/2.0;

// area of triangle
float area = sqrt(s*(s-vertices[0])*(s-vertices[1])*(s-vertices[2]));

return area;
}

int main()
{
float vertices[3];

printf("Enter vertex A: ");
scanf("%f",&vertices[0]);

printf("Enter vertex B: ");
scanf("%f",&vertices[1]);

printf("Enter vertex C: ");
scanf("%f",&vertices[2]);

//function cal
float area = Area(vertices);

//output
printf("With the given vertices %f, %f and %f the area of triangle is %f ",vertices[0],vertices[1],vertices[2], area);
return 0;
}