Question
Calculate the area of the polygon. Is there a way to modify this code to calculate the area of the polygon pictured? I don't have
Calculate the area of the polygon.
Is there a way to modify this code to calculate the area of the polygon pictured? I don't have much experience coding, and havent been able to figure it out?
---------------------------------------------
#include
using namespace std;
// (X[i], Y[i]) are coordinates of i'th point.
double polygonArea(double X[], double Y[], int n)
{
// Initialze area
double area = 0.0;
// Calculate value of shoelace formula
int j = n - 1;
for (int i = 0; i
{
area += (X[j] + X[i]) * (Y[j] - Y[i]);
j = i; // j is previous vertex to i
}
// Return absolute value
return abs(area / 2.0);
}
// Driver program to test above function
int main()
{
double X[] = {0, 2, 4};
double Y[] = {0, 3, 7};
int n = sizeof(X)/sizeof(X[0]);
cout
}
These are the hints below provided:
(6/5, 11/2) (9/2, 5) (3,4) (11/2,7/2) (16/5, 3/2) (6/5, 11/2) (9/2, 5) (3,4) (11/2,7/2) (16/5, 3/2)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started