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

In coordinate geometry, we can find the area of a triangle formed by the x-axis, y-axis, and a given straight line. When a straight line intersects both coordinate axes, it creates a triangle with the origin as one vertex.

Syntax

double calculateTriangleArea(double a, double b, double c);

Mathematical Formula

For a straight line with equation ax + by + c = 0, the intercept form is −

x/(-c/a) + y/(-c/b) = 1

The x-intercept is -c/a and y-intercept is -c/b. The area of the triangle formed is −

Area = (1/2) × |x-intercept| × |y-intercept| Area = |c²| / (2|ab|)

Geometric Visualization

A B O X-axis Y-axis ax + by + c = 0

Example

Here's a C program to calculate the area of triangle formed by coordinate axes and a straight line −

#include <stdio.h>
#include <math.h>

double calculateTriangleArea(double a, double b, double c) {
    /* Area = |c²| / (2|ab|) */
    return fabs((c * c) / (2 * a * b));
}

int main() {
    double a = -2, b = 4, c = 3;
    
    printf("Line equation: %.0fx + %.0fy + %.0f = 0<br>", a, b, c);
    printf("X-intercept: %.2f<br>", -c/a);
    printf("Y-intercept: %.2f<br>", -c/b);
    printf("Area of triangle: %.4f<br>", calculateTriangleArea(a, b, c));
    
    return 0;
}
Line equation: -2x + 4y + 3 = 0
X-intercept: -1.50
Y-intercept: 0.75
Area of triangle: 0.5625

Key Points

  • The line must intersect both axes to form a triangle (a ? 0 and b ? 0)
  • We use fabs() to ensure the area is always positive
  • The formula works for any orientation of the line

Conclusion

The area of triangle formed by coordinate axes and a straight line can be calculated using the formula |c²|/(2|ab|), where a, b, and c are coefficients from the line equation ax + by + c = 0.

Updated on: 2026-03-15T11:00:14+05:30

203 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements