A polygon is convex if it contains any line segmentsthat connects two points of the polygon. Write a program that prompts the userto enter the number of points in a convex polygon, enter the points clockwise,then displays the area of the polygon. Here isa sample run of the program: Enter the number of points: 7 ↵EnterEnter the coordinates of the points:−12 0 −8.5 10 0 11.4 5.5 7.8 6 -5.5 0 −7 −3.5 −13.5 ↵EnterThe total area is 292.575
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
A polygon is convex if it contains any line segments
that connects two points of the polygon. Write a
to enter the number of points in a convex polygon, enter the points clockwise,
then displays the area of the polygon.
Here is
a sample run of the program:
Enter the number of points: 7 ↵Enter
Enter the coordinates of the points:
−12 0 −8.5 10 0 11.4 5.5 7.8 6 -5.5 0 −7 −3.5 −13.5 ↵Enter
The total area is 292.575
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images