Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a c code Problem 2: Area of Polygon Resource: J.R. Hanly and E.B. Koffiman, Problem Solving and Program Design in C,8th Edition If n

write a c code image text in transcribed
Problem 2: Area of Polygon Resource: J.R. Hanly and E.B. Koffiman, 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 ani i.0 Notice that although the illustrated polygon has only six distinet 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, 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[1, double y)) //Read data from the text file //Output: two arrays: one for x and one for y 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[l, double yl, int size)t //Input: two arrays and size of the array (number of elements) //Output: area of the polygon 2) 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions