# Area of a triangle inside a parallelogram

Given the base and height of the parallelogram **ABCD** are **b and h** respectively. The task is to calculate the area of the triangle ▲ABM (M can be any point on upper side) constructed on the base **AB** of the parallelogram as shown below:

**Examples:**

Input: b = 30, h = 40 Output: 600.000000

**Approach:**

Area of a triangle constructed on the base of parallelogram and touching at any point on the opposite parallel side of the parallelogram can be given as = 0.5 * base * height

Hence, **Area of ▲ABM = 0.5 * b * h**

Below is the implementation of the above approach:

## C++

`#include <iostream> ` `using` `namespace` `std; ` ` ` `// function to calculate the area ` `float` `CalArea(` `float` `b, ` `float` `h) ` `{ ` ` ` `return` `(0.5 * b * h); ` `} ` `// driver code ` `int` `main() ` `{ ` ` ` `float` `b, h, Area; ` ` ` `b = 30; ` ` ` `h = 40; ` ` ` ` ` `// function calling ` ` ` `Area = CalArea(b, h); ` ` ` `// displaying the area ` ` ` `cout << ` `"Area of Triangle is :"` `<< Area; ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## C

`#include <stdio.h> ` ` ` `// function to calculate the area ` `float` `CalArea(` `float` `b, ` `float` `h) ` `{ ` ` ` `return` `(0.5 * b * h); ` `} ` ` ` `// driver code ` `int` `main() ` `{ ` ` ` `float` `b, h, Area; ` ` ` `b = 30; ` ` ` `h = 40; ` ` ` ` ` `// function calling ` ` ` `Area = CalArea(b, h); ` ` ` ` ` `// displaying the area ` ` ` `printf` `(` `"Area of Triangle is : %f\n"` `, Area); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`public` `class` `parallelogram { ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `double` `b = ` `30` `; ` ` ` `double` `h = ` `40` `; ` ` ` ` ` `// formula for calculating the area ` ` ` `double` `area_triangle = ` `0.5` `* b * h; ` ` ` ` ` `// displaying the area ` ` ` `System.out.println(` `"Area of the Triangle = "` `+ area_triangle); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python

`b ` `=` `30` `h ` `=` `40` ` ` `# formula for finding the area ` `area_triangle ` `=` `0.5` `*` `b ` `*` `h ` ` ` `# displaying the output ` `print` `(` `"Area of the triangle = "` `+` `str` `(area_triangle)) ` |

*chevron_right*

*filter_none*

## C#

`using` `System; ` `class` `parallelogram { ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `double` `b = 30; ` ` ` `double` `h = 40; ` ` ` ` ` `// formula for calculating the area ` ` ` `double` `area_triangle = 0.5 * b * h; ` ` ` ` ` `// displaying the area ` ` ` `Console.WriteLine(` `"Area of the triangle = "` `+ area_triangle); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` ` ` `$b` `= 30; ` ` ` `$h` `= 40; ` ` ` `$area_triangle` `=0.5*` `$b` `*` `$h` `; ` ` ` `echo` `"Area of the triangle = "` `; ` ` ` `echo` `$area_triangle` `; ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

Area of triangle is : 600.000000

## Recommended Posts:

- Perimeter and Area of Varignon's Parallelogram
- Program to find the Area of a Parallelogram
- Find area of parallelogram if vectors of two adjacent sides are given
- Triangle with no point inside
- Check whether a given point lies inside a triangle or not
- Count Integral points inside a Triangle
- Maximum number of 2x2 squares that can be fit inside a right isosceles triangle
- Area of a leaf inside a square
- Sum of Area of all possible square inside a rectangle
- Area of Reuleaux Triangle
- Area of Circumcircle of a Right Angled Triangle
- Check if right triangle possible from given area and hypotenuse
- Program to find area of a triangle
- Area of Incircle of a Right Angled Triangle
- Minimum height of a triangle with given base and area

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.