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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 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)

Sample Input:
Sample Output:
16.00
4
3 5
7 5
7 1
3 1
3 5
Sample Input:
Sample Output:
20.50
3 6
4 8
5 7
8 1
3 2
3 6
Sample Input:
Sample Output:
8.00
4 6
8 2
3 3
4 6
Transcribed Image Text:Sample Input: Sample Output: 16.00 4 3 5 7 5 7 1 3 1 3 5 Sample Input: Sample Output: 20.50 3 6 4 8 5 7 8 1 3 2 3 6 Sample Input: Sample Output: 8.00 4 6 8 2 3 3 4 6
If n points are connected to form a closed polygon as shown below, the area of the polygon
can be computed as
n-2
Area = (2) E (Xi+1 + Xi ) (yi+1 - yi )
i=0
y
(x1,Y1)
(Xo,Yo)=
(X6,Y6)
(X2,y2)
(X3,Y3)
(Xs,Ys)
(X4,Ya)
n=7
Transcribed Image Text:If n points are connected to form a closed polygon as shown below, the area of the polygon can be computed as n-2 Area = (2) E (Xi+1 + Xi ) (yi+1 - yi ) i=0 y (x1,Y1) (Xo,Yo)= (X6,Y6) (X2,y2) (X3,Y3) (Xs,Ys) (X4,Ya) n=7
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY