# Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given

Given three integers **d**, **h1**,** h2** where **d** represents the length of the diagonal of a quadrilateral. **h1** and **h2** represents the lengths of the perpendiculars to the given diagonal from the opposite vertices. The task is to find the area of the Quadrilateral.

**Examples:**

Input :d= 6, h1 = 4, h2 = 3

Output :21

Input :d= 10, h1 = 8, h2 = 10

Output :90

**Approach :**

Area of the quadrilateral is the sum of the areas of both triangles. We know that the area of the triangle is 1/2*base*height.

Therefore, the area of a quadrilateral can be calculated as :

Area = 1/2 * d * h1 + 1/2 * d * h2

= 1/2 * d * ( h1 + h2 )

Below is the implementation of the above approach :

## C++

`// C++ program to find the area of quadrilateral ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the area of quadrilateral ` `float` `Area(` `int` `d, ` `int` `h1, ` `int` `h2) ` `{ ` ` ` `float` `area; ` ` ` ` ` `area = 0.5 * d * (h1 + h2); ` ` ` ` ` `return` `area; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `d = 6, h1 = 4, h2 = 3; ` ` ` ` ` `cout << ` `"Area of Quadrilateral = "` `<< (Area(d, h1, h2)); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find the area of quadrilateral ` `class` `GFG ` `{ ` ` ` ` ` `// Function to find the area of quadrilateral ` ` ` `static` `float` `Area(` `int` `d, ` `int` `h1, ` `int` `h2) ` ` ` `{ ` ` ` `float` `area; ` ` ` ` ` `area = (` `float` `) ` `0.5` `* d * (h1 + h2); ` ` ` ` ` `return` `area; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `d = ` `6` `, h1 = ` `4` `, h2 = ` `3` `; ` ` ` ` ` `System.out.println(` `"Area of Quadrilateral = "` `+ ` ` ` `Area(d, h1, h2)); ` ` ` `} ` `} ` ` ` `// This code is contributed by Princi Singh ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find ` `# the area of quadrilateral ` ` ` `# Function to find the ` `# area of quadrilateral ` `def` `Area(d, h1, h2): ` ` ` ` ` `area ` `=` `0.5` `*` `d ` `*` `(h1 ` `+` `h2); ` ` ` ` ` `return` `area; ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` ` ` `d ` `=` `6` `; ` ` ` `h1 ` `=` `4` `; ` ` ` `h2 ` `=` `3` `; ` ` ` ` ` `print` `(` `"Area of Quadrilateral = "` `, ` ` ` `(Area(d, h1, h2))); ` ` ` `# This code is contributed by Rajput-Ji ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find the area of quadrilateral ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find the area of quadrilateral ` `static` `float` `Area(` `int` `d, ` `int` `h1, ` `int` `h2) ` `{ ` ` ` `float` `area; ` ` ` ` ` `area = (` `float` `)0.5 * d * (h1 + h2); ` ` ` ` ` `return` `area; ` `} ` ` ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `d = 6, h1 = 4, h2 = 3; ` ` ` ` ` `Console.WriteLine(` `"Area of Quadrilateral = "` `+ ` ` ` `Area(d, h1, h2)); ` `} ` `} ` ` ` `// This code is contributed by nidhiva ` |

*chevron_right*

*filter_none*

**Output:**

Area of Quadrilateral = 21

## Recommended Posts:

- Find two vertices of an isosceles triangle in which there is rectangle with opposite corners (0, 0) and (X, Y)
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
- Maximum area of quadrilateral
- Area of a polygon with given n ordered vertices
- Area of a square from diagonal length
- Calculate area of pentagon with given diagonal
- Area of hexagon with given diagonal length
- Program to calculate area of a rhombus whose one side and diagonal are given
- Program to find the angles of a quadrilateral
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Find the diagonal of the Cube
- Find the cordinates of the fourth vertex of a rectangle with given 3 vertices
- Find length of Diagonal of Hexagon
- Find the number of distinct pairs of vertices which have a distance of exactly k in a tree
- Find a Symmetric matrix of order N that contain integers from 0 to N-1 and main diagonal should contain only 0's

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.