# Area of the biggest ellipse inscribed within a rectangle

Given here is a rectangle of length **l** & breadth **b**, the task is to find the area of the biggest ellipse that can be inscribed within it.

**Examples:**

Input:l = 5, b = 3Output:11.775Input:7, b = 4Output:21.98

**Approach**:

- Let, the length of the major axis of the ellipse =
**2x**and the length of the minor axis of the ellipse =**2y** - From the diagram, it is very clear that,

**2x = l**

2y = b - So,
**Area of the ellipse**=**(π * x * y)**=**(π * l * b) / 4**

Below is the implementation of the above approach:

## C++

`// C++ Program to find the biggest ellipse ` `// which can be inscribed within the rectangle ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the area ` `// of the ellipse ` `float` `ellipse(` `float` `l, ` `float` `b) ` `{ ` ` ` ` ` `// The sides cannot be negative ` ` ` `if` `(l < 0 || b < 0) ` ` ` `return` `-1; ` ` ` ` ` `// Area of the ellipse ` ` ` `float` `x = (3.14 * l * b) / 4; ` ` ` ` ` `return` `x; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `l = 5, b = 3; ` ` ` `cout << ellipse(l, b) << endl; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java Program to find the biggest rectangle ` `// which can be inscribed within the ellipse ` `import` `java.util.*; ` `import` `java.lang.*; ` `import` `java.io.*; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find the area ` `// of the rectangle ` `static` `float` `ellipse(` `float` `l, ` `float` `b) ` `{ ` ` ` ` ` `// a and b cannot be negative ` ` ` `if` `(l < ` `0` `|| b < ` `0` `) ` ` ` `return` `-` `1` `; ` ` ` `float` `x = (` `float` `)(` `3.14` `* l * b) / ` `4` `; ` ` ` ` ` `return` `x; ` ` ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String args[]) ` `{ ` ` ` `float` `a = ` `5` `, b = ` `3` `; ` ` ` `System.out.println(ellipse(a, b)); ` `} ` `} ` ` ` `// This code is contributed ` `// by Mohit Kumar ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 Program to find the biggest ellipse ` `# which can be inscribed within the rectangle ` ` ` `# Function to find the area ` `# of the ellipse ` `def` `ellipse(l, b): ` ` ` ` ` `# The sides cannot be negative ` ` ` `if` `l < ` `0` `or` `b < ` `0` `: ` ` ` `return` `-` `1` ` ` ` ` `# Area of the ellipse ` ` ` `x ` `=` `(` `3.14` `*` `l ` `*` `b) ` `/` `4` ` ` ` ` `return` `x ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `l, b ` `=` `5` `, ` `3` ` ` `print` `(ellipse(l, b)) ` ` ` `# This code is contributed ` `# by Rituraj Jain ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to find the biggest rectangle ` `// which can be inscribed within the ellipse ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find the area ` `// of the rectangle ` `static` `float` `ellipse(` `float` `l, ` `float` `b) ` `{ ` ` ` ` ` `// a and b cannot be negative ` ` ` `if` `(l < 0 || b < 0) ` ` ` `return` `-1; ` ` ` `float` `x = (` `float` `)(3.14 * l * b) / 4; ` ` ` ` ` `return` `x; ` ` ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `float` `a = 5, b = 3; ` ` ` `Console.WriteLine(ellipse(a, b)); ` `} ` `} ` ` ` `// This code is contributed ` `// by Code_Mech. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find the biggest ellipse ` `// which can be inscribed within the rectangle ` ` ` `// Function to find the area ` `// of the ellipse ` `function` `ellipse(` `$l` `, ` `$b` `) ` `{ ` ` ` ` ` `// The sides cannot be negative ` ` ` `if` `(` `$l` `< 0 || ` `$b` `< 0) ` ` ` `return` `-1; ` ` ` ` ` `// Area of the ellipse ` ` ` `$x` `= (3.14 * ` `$l` `* ` `$b` `) / 4; ` ` ` ` ` `return` `$x` `; ` `} ` ` ` `// Driver code ` `$l` `= 5; ` `$b` `= 3; ` `echo` `ellipse(` `$l` `, ` `$b` `) . ` `"\n"` `; ` ` ` `// This code is contributed ` `// by Akanksha Rai ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

11.775

## Recommended Posts:

- Area of a triangle inscribed in a rectangle which is inscribed in an ellipse
- Area of Largest rectangle that can be inscribed in an Ellipse
- Area of the biggest possible rhombus that can be inscribed in a rectangle
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse
- Largest ellipse that can be inscribed within a rectangle which in turn is inscribed within a semicircle
- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- The biggest possible circle that can be inscribed in a rectangle
- Area of a circle inscribed in a rectangle which is inscribed in a semicircle
- Ratio of area of a rectangle with the rectangle inscribed in it
- Area of the Largest square that can be inscribed in an ellipse
- Find the area of largest circle inscribed in ellipse
- Area of largest triangle that can be inscribed within a rectangle
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle

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.