Given a semicircle with radius **R**, which inscribes a rectangle of length **L** and breadth **B**, which in turn inscribes a circle of radius **r**. The task is to find the area of the circle with radius r.

**Examples:**

Input : R = 2 Output : 1.57 Input : R = 5 Output : 9.8125

**Approach**:

We know the biggest rectangle that can be inscribed within the semicircle has, length,

l=√2R/2&

breadth,b=R/√2(Please refer)

Also, the biggest circle that can be inscribed within the rectangle has radius,r=b/2=R/2√2(Please refer)

So area of the circle,A=π*r^2=π(R/2√2)^2

## C++

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

*chevron_right*

*filter_none*

## Java

`// Java Program to find the area of the circle ` `// inscribed within the rectangle which in turn ` `// is inscribed in a semicircle ` ` ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` ` ` `// Function to find the area of the circle ` `static` `float` `area(` `float` `r) ` `{ ` ` ` ` ` `// radius cannot be negative ` ` ` `if` `(r < ` `0` `) ` ` ` `return` `-` `1` `; ` ` ` ` ` `// area of the circle ` ` ` `float` `area = (` `float` `)(` `3.14` `* Math.pow(r / (` `2` `* Math.sqrt(` `2` `)), ` `2` `)); ` ` ` `return` `area; ` `} ` ` ` `// Driver code ` ` ` ` ` `public` `static` `void` `main (String[] args) { ` ` ` `float` `a = ` `5` `; ` ` ` `System.out.println( area(a)); ` ` ` `} ` `} ` ` ` ` ` `// This code is contributed by ajit ` |

*chevron_right*

*filter_none*

## Python3

`# Python 3 Program to find the ` `# area of the circle inscribed ` `# within the rectangle which in ` `# turn is inscribed in a semicircle ` `from` `math ` `import` `pow` `, sqrt ` ` ` `# Function to find the area ` `# of the circle ` `def` `area(r): ` ` ` ` ` `# radius cannot be negative ` ` ` `if` `(r < ` `0` `): ` ` ` `return` `-` `1` ` ` ` ` `# area of the circle ` ` ` `area ` `=` `3.14` `*` `pow` `(r ` `/` `(` `2` `*` `sqrt(` `2` `)), ` `2` `); ` ` ` ` ` `return` `area; ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` `a ` `=` `5` ` ` `print` `(` `"{0:.6}"` `.` `format` `(area(a))) ` ` ` `# This code is contributed By ` `# Surendra_Gangwar ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to find the area of ` `// the circle inscribed within the ` `// rectangle which in turn is ` `// inscribed in a semicircle ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find the area ` `// of the circle ` `static` `float` `area(` `float` `r) ` `{ ` ` ` ` ` `// radius cannot be negative ` ` ` `if` `(r < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the circle ` ` ` `float` `area = (` `float` `)(3.14 * Math.Pow(r / ` ` ` `(2 * Math.Sqrt(2)), 2)); ` ` ` `return` `area; ` `} ` ` ` `// Driver code ` `static` `public` `void` `Main (String []args) ` `{ ` ` ` `float` `a = 5; ` ` ` `Console.WriteLine(area(a)); ` `} ` `} ` ` ` `// This code is contributed ` `// by Arnab Kundu ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find the area ` `// of the circle inscribed within ` `// the rectangle which in turn ` `// is inscribed in a semicircle ` ` ` `// Function to find the area ` `// of the circle ` `function` `area(` `$r` `) ` `{ ` ` ` `// radius cannot be negative ` ` ` `if` `(` `$r` `< 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the circle ` ` ` `$area` `= 3.14 * pow(` `$r` `/ ` ` ` `(2 * sqrt(2)), 2); ` ` ` `return` `$area` `; ` `} ` ` ` `// Driver code ` `$a` `= 5; ` `echo` `area(` `$a` `); ` ` ` `// This code is contributed by mits ` |

*chevron_right*

*filter_none*

**Output:**

9.8125

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
- Area of largest Circle that can be inscribed in a SemiCircle
- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- Area of a triangle inscribed in a rectangle which is inscribed in an ellipse
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Area of a square inscribed in a circle which is inscribed in a hexagon
- Ratio of area of a rectangle with the rectangle inscribed in it
- Area of the circle that has a square and a circle inscribed in it
- 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
- Largest triangle that can be inscribed in a semicircle
- Largest square that can be inscribed in a semicircle
- Largest trapezoid that can be inscribed in a semicircle
- Biggest Reuleaux Triangle inscirbed within a square inscribed in a semicircle
- Area of the biggest possible rhombus that can be inscribed in a rectangle
- Area of Largest rectangle that can be inscribed in an Ellipse
- Area of largest triangle that can be inscribed within a rectangle
- Area of the biggest ellipse inscribed within a rectangle
- Maximum area of rectangle inscribed in an equilateral triangle
- Program to find the Area and Perimeter of 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.