Question: Please write in code C. Concepts: Array and Array with user-defined functions Problem 2: Area of Polygoin Resource: J.R. Hanly and E.B. Koffman, Problem Solving
Please write in code C.
Concepts:
Array and Array with user-defined functions


Problem 2: Area of Polygoin Resource: J.R. Hanly and E.B. Koffman, Problem Solving and Program Design in C,8th Edition If n points are connected to form a closed polygon as shown below, the area A of the polygon can be computed as (Xi Vi) (xs.Ve) (x2 y2) (x3.y3) n=7 Notice that although the illustrated polygon has only six distinct corners, n for this polygon is 7 because the algorithm expects that the last point, (x6, y6), will be a repeat of the initial point, (x0., 0) Write a C program to find the area of the polygon by Represent the (x, y) coordinates of the connected points as two arrays with the size n 7 (one array keep values of x coordinate for all n points and the other keeps the values of y coordinate for all n points) Using the following two user-defined functions: 1) get corners function: Read from an input text file "polygon.txt" for array x and y. The function prototype is void get_cornerS (FILE *inp, double x[], double y[]) //Read data from the text file //Output: two arrays: one for x and one for y 2) polygon area function: Takes as parameters two arrays x, y, and its size (number of elements in the array), and returns the area of the polygon double polygon_area (double x[], double y[], int size){ //Input: two arrays and size of the array (number of elements) //Output: area of the polygon Use the for/while loop in your program to read the data from the text file and to access the arrays for the area calculation * If your program does not use the loop, you will get 0 point for this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
