Given here is an ellipse with axes length **2a** and **2b**, which inscribes a rectangle of length **l** and breadth **h**, which in turn inscribes a triangle.The task is to find the area of this triangle.

**Examples:**

Input: a = 4, b = 3 Output: 12 Input: a = 5, b = 2 Output: 10

**Approach**:

We know the Area of the rectangle inscribed within the ellipse is, **Ar = 2ab**(Please refer here),

also the area of the triangle inscribed within the rectangle s, **A = Ar/2 = ab**(Please refer here)

**Below is the implementation of the above approach**:

## C++

`// C++ Program to find the area of the triangle ` `// inscribed within the rectangle which in turn ` `// is inscribed in an ellipse ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the area of the triangle ` `float` `area(` `float` `a, ` `float` `b) ` `{ ` ` ` ` ` `// length of a and b cannot be negative ` ` ` `if` `(a < 0 || b < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the triangle ` ` ` `float` `A = a * b; ` ` ` `return` `A; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `a = 5, b = 2; ` ` ` `cout << area(a, b) << endl; ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

` ` `// Java Program to find the area of the triangle ` `// inscribed within the rectangle which in turn ` `// is inscribed in an ellipse ` ` ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` `// Function to find the area of the triangle ` `static` `float` `area(` `float` `a, ` `float` `b) ` `{ ` ` ` ` ` `// length of a and b cannot be negative ` ` ` `if` `(a < ` `0` `|| b < ` `0` `) ` ` ` `return` `-` `1` `; ` ` ` ` ` `// area of the triangle ` ` ` `float` `A = a * b; ` ` ` `return` `A; ` `} ` ` ` `// Driver code ` ` ` ` ` ` ` `public` `static` `void` `main (String[] args) { ` ` ` `float` `a = ` `5` `, b = ` `2` `; ` ` ` `System.out.println(area(a, b)); ` ` ` `} ` `} ` `//This code is contributed by anuj_67.. ` |

*chevron_right*

*filter_none*

## Python3

`# Python 3 Program to find the ` `# area of the triangle inscribed ` `# within the rectangle which in ` `# turn is inscribed in an ellipse ` ` ` `# Function to find the area ` `# of the triangle ` `def` `area(a, b): ` ` ` ` ` `# length of a and b cannot ` ` ` `# be negative ` ` ` `if` `(a < ` `0` `or` `b < ` `0` `): ` ` ` `return` `-` `1` ` ` ` ` `# area of the triangle ` ` ` `A ` `=` `a ` `*` `b ` ` ` `return` `A ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` `a ` `=` `5` ` ` `b ` `=` `2` ` ` `print` `(area(a, b)) ` ` ` `# This code is contributed ` `# by Surendra_Gangwar ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to find the area of ` `// the triangle inscribed within ` `// the rectangle which in turn ` `// is inscribed in an ellipse ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find the ` `// area of the triangle ` `static` `float` `area(` `float` `a, ` `float` `b) ` `{ ` ` ` ` ` `// length of a and b ` ` ` `// cannot be negative ` ` ` `if` `(a < 0 || b < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the triangle ` ` ` `float` `A = a * b; ` ` ` `return` `A; ` `} ` ` ` `// Driver code ` `static` `public` `void` `Main () ` `{ ` ` ` `float` `a = 5, b = 2; ` ` ` `Console.WriteLine(area(a, b)); ` `} ` `} ` ` ` `// This code is contributed by ajit ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find the area ` `// of the triangle inscribed within ` `// the rectangle which in turn ` `// is inscribed in an ellipse ` ` ` `// Function to find the ` `// area of the triangle ` `function` `area(` `$a` `, ` `$b` `) ` `{ ` ` ` ` ` `// length of a and b cannot ` ` ` `// be negative ` ` ` `if` `(` `$a` `< 0 || ` `$b` `< 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the triangle ` ` ` `$A` `= ` `$a` `* ` `$b` `; ` ` ` `return` `$A` `; ` `} ` ` ` `// Driver code ` `$a` `= 5; ` `$b` `= 2; ` `echo` `area(` `$a` `, ` `$b` `); ` ` ` `// This code is contributed ` `// by Mahadev99 ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

10

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Largest ellipse that can be inscribed within a rectangle which in turn is inscribed within a semicircle
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse
- Area of a circle inscribed in a rectangle which is inscribed in a semicircle
- Area of Largest rectangle that can be inscribed in an Ellipse
- Area of the biggest ellipse inscribed within a rectangle
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Ratio of area of a rectangle with the rectangle inscribed in it
- Area of largest triangle that can be inscribed within a rectangle
- Maximum area of rectangle inscribed in an equilateral triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon
- Area of a square inscribed in a circle which is inscribed in a hexagon
- Largest triangle that can be inscribed in an ellipse
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Area of the Largest square that can be inscribed in an ellipse
- Find the area of largest circle inscribed in ellipse
- Area of circle which is inscribed in equilateral triangle
- Maximum area of a Rectangle that can be circumscribed about a given Rectangle of size LxW

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.