- Related Questions & Answers
- Area of a n-sided regular polygon with given Radius?
- Area of a n-sided regular polygon with given Radius in C Program?
- Area of a n-sided regular polygon with given side length in C++
- Area of largest Circle inscribed in N-sided Regular polygon in C Program?
- Area of largest Circle inscribe in N-sided Regular polygon in C Program?
- Apothem of a n-sided regular polygon in C++
- Construct a graph from given degrees of all vertices in C++
- Check if it is possible to create a polygon with given n sidess in Python
- Count ordered pairs with product less than N in C++
- Minimum height of a triangle with given base and area in C++
- Area of hexagon with given diagonal length in C Program?
- Maximum area of rectangle possible with given perimeter in C++
- Finding the simple non-isomorphic graphs with n vertices in a graph
- Maximum number of ones in a N*N matrix with given constraints in C++
- C Program for area of hexagon with given diagonal length?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this program, we have to find the area of a polygon. The coordinates of the vertices of this polygon are given. Before we move further lets brushup old concepts for a better understanding of the concept that follows.

**The area** is the quantitative representation of the extent of any two-dimensional figure.

**Polygon** is a closed figure with a given number of sides.

**Coordinates** of vertices are the value of points in the 2-d plane. For example (0,0).

Now, let's see the mathematical formula for finding the area.

Area = ½ [(x1y2 + x2y3 + …… + x(n-1)yn + xny1) - (x2y1 + x3y2 + ……. + xny(n-1) + x1yn ) ]

Using this formula the area can be calculated,

#include <iostream> #include <math.h> using namespace std; double areaOfPolygon(double x[], double y[], int n){ double area = 0.0; int j = n - 1; for (int i = 0; i < n; i++){ area += (x[j] + x[i]) * (y[j] - y[i]); j = i; } return abs(area / 2.0); } int main(){ double X[] = {0, 1, 4, 8}; double Y[] = {0, 2, 5, 9}; int n = sizeof(X)/sizeof(X[0]); cout<<"The area is "<<areaOfPolygon(X, Y, n); }

The area is 3.5

Advertisements