Area of triangle formed by the axes of co-ordinates and a given straight line?



Here we will see how to get the area of a triangle formed by the x and y axis and another straight line. The diagram will be look like below. The equation of the straight line is βˆ’

??+??+?=0

The line is cutting the x-axis at the point B, and cutting the y-axis at the point A. The intercept form will be like below βˆ’

So the x-intercept is βˆ’??? and y-intercept is βˆ’??? . So the area of the triangle is

Example

Β Live Demo

#include<iostream>
#include<cmath>
using namespace std;
double areaTriangle(double a, double b, double c){
Β  Β return fabs((c*c) / (2*a*b));
}
main() {
Β  Β double a = -2, b = 4, c = 3;
Β  Β cout << "Area: " << areaTriangle(a, b, c);
}

Output

Area: 0.5625
Updated on: 2019-07-30T22:30:26+05:30

144 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements