- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

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

#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); }

Area: 0.5625

- Related Questions & Answers
- Represent a Given Set of Points by the Best Possible Straight Line in C++
- Minimum height of a triangle with given base and area in C++
- Area of Reuleaux Triangle?
- Area of squares formed by joining midpoints repeatedly in C?
- Golang Program to Find the Area of a Triangle Given All Three Sides
- Area of Circumcircle of a Right Angled Triangle?
- Java program to find the area of a triangle
- How to Calculate the Area of a Triangle using Python?
- Program to calculate area and perimeter of equilateral triangle
- Check if a triangle of positive area is possible with the given angles in Python
- Find the altitude and area of an isosceles triangle in C++
- Area of squares formed by joining mid points repeatedly in C Program?
- Area of a triangle inside a parallelogram in C++
- C++ Program to Compute the Area of a Triangle Using Determinants
- Area of the Largest Triangle inscribed in a Hexagon in C++

Advertisements