Using recursion write a program to compute the area of a pol
     Using recursion, write a program to compute the area of a polygon shown. You can use the vertices 1, 2 and 3 and cut off a triangle and use the fact that a triangle with points 1(x1, y1), 2(x2, y2) and 3(x3, y3) as corners, has an area of  area = (x_1y_2 + x_2y_3 + x_3y_1 - y_1x_2 - y_2x_3 - y_3x_1)/2  Then move to vertices 1, 3, and 4 and do the area calculation continue with 1, 4, and 5 and then 1, 5, and 6 to do the same. You stop the recursion when you run out of triangles.   
  
  Solution
Since no language is specified, I am assuming it to be C++
#include <iostream>
 using namespace std;
float abs( float a ){
    if( a< 0){ a*= -1;}
    return a;
 }
float calculate_area( float* x, float* y, int n ){
    // x: x co-ordinates ,   y: y co-ordinates
    // n is total sides of the polygon
    float area = 0;
    for(int i = 1; i < n-1; i++ ){
        //clculate area of triangle made by points 0, i, i+1
        area += abs(( x[0]*y[i] + x[i]*y[i+1] + x[i+1]*y[0] - y[0]*x[i] - y[i]*x[i+1] - y[i+1]*x[0] )/2.0 );
    }
    return area;
 }
int main(){
    float x[4] = {-1,1,1,-1};
    float y[4] = {1,1,-1,-1};
    cout << calculate_area(x, y, 4) << endl;
 }

