Notice that although the illustrated polygon has only 6 distinct corners, n for this polygon is 7 because the algorithm expects that the last point (x6,y6) will be repeat of the initial point, (x0,y0). Define a structure for a point. Each point contains x coordinate and y coordinate. The representation of a Polygon must be a stack of structures in your program. Write a C program that takes the number of actual points (n-1) from the user. After that, user enters x and y coordinates of each point. (The last point will be repeat of the initial point). When you read
Notice that although the illustrated polygon has only 6 distinct corners, n for this polygon is 7
because the
Define a structure for a point. Each point contains x coordinate and y coordinate. The
representation of a Polygon must be a stack of structures in your
Write a C program that takes the number of actual points (n-1) from the user. After that, user
enters x and y coordinates of each point. (The last point will be repeat of the initial point).
When you read the coordinates form the user, they are placed on your stack. In your
computation, you will get the coordinates from the stack.
Write a computeArea function which returns the area of the Polygon. Print the area of the
Polygon in main. Display the area with two digits after the decimal point.
Note: The absolute value can be computed with fabs function.
Example:
double x = - 5.0; fabs(x) is 5.0
double x = 0.0; fabs(x) is 0.0
double x = 5.0; fabs(x) is 5.0
(should write in c language)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images