Given here is a semicircle of radius **r**, which inscribes a rectangle which in turn inscribes an ellipse. The task is to find the area of this largest ellipse.

**Examples:**

Input:r = 5Output:19.625Input:r = 11Output:94.985

**Approach**:

- Let the, length of the rectangle =
**l**and breadth of the rectangle =**b** - Let, the length of the major axis of the ellipse =
**2x**and, the length of the minor axis of the ellipse =**2y** - As we know, length and breadth of the largest rectangle inside a semicircle are
**r/√2**and**√2r**(Please refer here) - Also, Area of the ellipse within the rectangle =
**(π*l*b)/4**=**(πr^2/4)**

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

## C++

`// C++ Program to find the biggest ellipse ` `// which can be inscribed within a rectangle ` `// which in turn is inscribed within a semicircle ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the area ` `// of the biggest ellipse ` `float` `ellipsearea(` `float` `r) ` `{ ` ` ` ` ` `// the radius cannot be negative ` ` ` `if` `(r < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the ellipse ` ` ` `float` `a = (3.14 * r * r) / 4; ` ` ` ` ` `return` `a; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `r = 5; ` ` ` `cout << ellipsearea(r) << endl; ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java Program to find the biggest ellipse ` `// which can be inscribed within a rectangle ` `// which in turn is inscribed within a semicircle ` `class` `GFG ` `{ ` ` ` `// Function to find the area ` `// of the biggest ellipse ` `static` `float` `ellipsearea(` `float` `r) ` `{ ` ` ` ` ` `// the radius cannot be negative ` ` ` `if` `(r < ` `0` `) ` ` ` `return` `-` `1` `; ` ` ` ` ` `// area of the ellipse ` ` ` `float` `a = (` `float` `)((` `3` `.14f * r * r) / ` `4` `); ` ` ` ` ` `return` `a; ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `float` `r = ` `5` `; ` ` ` `System.out.println(ellipsearea(r)); ` `} ` `} ` ` ` `// This code is contributed by Code_Mech. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 Program to find the biggest ellipse ` `# which can be inscribed within a rectangle ` `# which in turn is inscribed within a semicircle ` ` ` `# Function to find the area of ` `# the biggest ellipse ` `def` `ellipsearea(r) : ` ` ` ` ` `# the radius cannot be negative ` ` ` `if` `(r < ` `0` `) : ` ` ` `return` `-` `1` `; ` ` ` ` ` `# area of the ellipse ` ` ` `a ` `=` `(` `3.14` `*` `r ` `*` `r) ` `/` `4` `; ` ` ` ` ` `return` `a; ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `r ` `=` `5` `; ` ` ` `print` `(ellipsearea(r)); ` ` ` `# This code is contributed by Ryuga ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to find the biggest ellipse ` `// which can be inscribed within a rectangle ` `// which in turn is inscribed within a semicircle ` `using` `System; ` `class` `GFG ` `{ ` ` ` `// Function to find the area ` `// of the biggest ellipse ` `static` `float` `ellipsearea(` `float` `r) ` `{ ` ` ` ` ` `// the radius cannot be negative ` ` ` `if` `(r < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the ellipse ` ` ` `float` `a = (` `float` `)((3.14 * r * r) / 4); ` ` ` ` ` `return` `a; ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `float` `r = 5; ` ` ` `Console.WriteLine(ellipsearea(r)); ` `} ` `} ` ` ` `// This code is contributed by Akanksha Rai ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find the biggest ellipse ` `// which can be inscribed within a rectangle ` `// which in turn is inscribed within a semicircle ` ` ` `// Function to find the area ` `// of the biggest ellipse ` `function` `ellipsearea(` `$r` `) ` `{ ` ` ` ` ` `// the radius cannot be negative ` ` ` `if` `(` `$r` `< 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the ellipse ` ` ` `$a` `= (3.14 * ` `$r` `* ` `$r` `) / 4; ` ` ` ` ` `return` `$a` `; ` `} ` ` ` `// Driver code ` `$r` `= 5; ` `echo` `ellipsearea(` `$r` `) . ` `"\n"` `; ` ` ` `// This code is contributed by Akanksha Rai ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

19.625

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:

- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- 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 a triangle inscribed in a rectangle which is inscribed in an ellipse
- Largest right circular cylinder that can be inscribed within a cone which is in turn inscribed within a cube
- Largest sphere that can be inscribed within a cube which is in turn inscribed within a right circular cone
- Largest triangle that can be inscribed in a semicircle
- Largest trapezoid that can be inscribed in a semicircle
- Largest square that can be inscribed in a semicircle
- Area of the biggest ellipse inscribed within a rectangle
- Area of largest Circle that can be inscribed in a SemiCircle
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse
- Largest triangle that can be inscribed in an ellipse
- 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
- Largest right circular cone that can be inscribed within a sphere which is inscribed within a cube
- Largest sphere that can be inscribed in a right circular cylinder inscribed in a frustum
- Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle
- Biggest Reuleaux Triangle inscirbed within a square inscribed in a semicircle

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.