# Area of a circle inscribed in a regular hexagon

Given a regular Hexagon with side length **a**, the task is to find the area of the circle inscribed in it, given that, the circle is tangent to each of the six sides.

**Examples:**

Input: a = 4 Output: 37.68 Input: a = 10 Output: 235.5

**Approach**:

From the figure, it is clear that, we can divide the regular hexagon into 6 identical equilateral triangles.

We take one triangle **OAB**, with **O** as the centre of the hexagon or circle, & **AB** as one side of the hexagon.

Let **M** be mid-point of **AB**, **OM** would be the perpendicular bisector of **AB**, **angle AOM = 30 deg**

Then in right angled triangle **OAM,**

tanx = tan30 = 1/√3

So,a/2r = 1/√3

Therefore,r = a√3/2

Area of circle,A =Πr²=Π3a^2/4

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

## C++

`// C++ Program to find the area of the circle ` `// which can be inscribed within the hexagon ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the area ` `// of the inscribed circle ` `float` `circlearea(` `float` `a) ` `{ ` ` ` ` ` `// the side cannot be negative ` ` ` `if` `(a < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the circle ` ` ` `float` `A = (3.14 * 3 * ` `pow` `(a, 2)) / 4; ` ` ` ` ` `return` `A; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `a = 4; ` ` ` `cout << circlearea(a) << endl; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`//Java program to find the ` `//area of the circle ` `//which can be inscribed within the hexagon ` ` ` `import` `java.util.*; ` ` ` `class` `solution ` `{ ` `static` `double` `circlearea(` `double` `a) ` `{ ` ` ` `// the side cannot be negative ` ` ` `if` `(a < ` `0` `) ` ` ` `return` `-` `1` `; ` ` ` `// area of the circle ` ` ` `double` `A = (` `3.14` `* ` `3` `* Math.pow(a,` `2` `) ) / ` `4` `; ` ` ` ` ` `return` `A; ` `} ` `public` `static` `void` `main(String arr[]) ` `{ ` ` ` `double` `a = ` `4` `; ` ` ` `System.out.println(circlearea(a)); ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python 3

`# Python 3 program to find the ` `# area of the circle ` `# which can be inscribed within the hexagon ` ` ` `# Function to find the area ` `# of the inscribed circle ` `def` `circlearea(a) : ` ` ` ` ` `# the side cannot be negative ` ` ` `if` `a < ` `0` `: ` ` ` `return` `-` `1` ` ` ` ` `# area of the circle ` ` ` `A ` `=` `(` `3.14` `*` `3` `*` `pow` `(a,` `2` `)) ` `/` `4` ` ` ` ` `return` `A ` ` ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `a ` `=` `4` ` ` `print` `(circlearea(a)) ` ` ` ` ` `# This code is contributed by ANKITRAI1 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find ` `// the area of the circle ` `// which can be inscribed ` `// within the hexagon ` `using` `System; ` ` ` `class` `GFG ` `{ ` `static` `double` `circlearea(` `double` `a) ` `{ ` ` ` ` ` `// the side cannot be negative ` ` ` `if` `(a < 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the circle ` ` ` `double` `A = (3.14 * 3 * ` ` ` `Math.Pow(a, 2)) / 4; ` ` ` ` ` `return` `A; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` `double` `a = 4; ` ` ` `Console.WriteLine(circlearea(a)); ` `} ` `} ` ` ` `// This code is contributed ` `// by inder_verma ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find the area of ` `// the circle which can be inscribed ` `// within the hexagon ` ` ` `// Function to find the area ` `// of the inscribed circle ` `function` `circlearea(` `$a` `) ` `{ ` ` ` ` ` `// the side cannot be negative ` ` ` `if` `(` `$a` `< 0) ` ` ` `return` `-1; ` ` ` ` ` `// area of the circle ` ` ` `$A` `= (3.14 * 3 * pow(` `$a` `, 2)) / 4; ` ` ` ` ` `return` `$A` `; ` `} ` ` ` `// Driver code ` `$a` `= 4; ` `echo` `circlearea(` `$a` `) . ` `"\n"` `; ` ` ` `// This code is contributed ` `// by Akanksha Rai(Abby_akku) ` |

*chevron_right*

*filter_none*

**Output:**

37.68

## Recommended Posts:

- Area of a square inscribed in a circle which is inscribed in a hexagon
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Area of the Largest Triangle inscribed in a Hexagon
- Area of a circle inscribed in a rectangle which is inscribed in a semicircle
- Area of the circle that has a square and a circle inscribed in it
- Area of circle inscribed within rhombus
- Area of decagon inscribed within the circle
- Area of circle which is inscribed in equilateral triangle
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Find the area of largest circle inscribed in ellipse
- Program to calculate area of an Circle inscribed in a Square
- Area of largest Circle inscribe in N-sided Regular polygon
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon
- Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle
- Find area of the larger circle when radius of the smaller circle and difference in the area is given

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.