Related Articles

# Area of a square inscribed in a circle which is inscribed in a hexagon

• Last Updated : 16 Mar, 2021

Given a regular hexagon with side A, which inscribes a circle of radius r, which in turn inscribes a square of side a.The task is to find the area of this square.
Examples

Input :  A = 5
Output : 37.5

Input : A = 8
Output : 96

Approach
We know the radius of the circle inscribed within the hexagon is, r=A√3/2(Please refer here
Also, side length of circle within the circle is, a=√r=√3A/√2
So, Area of the Square, Area=(√3A/√2)^2

## C++

 // C++ Program to find the area of the square// inscribed within the circle which in turn// is inscribed in a hexagon#include using namespace std; // Function to find the area of the squarefloat area(float a){     // side of hexagon cannot be negative    if (a < 0)        return -1;     // area of the square    float area = pow((a * sqrt(3)) / (sqrt(2)), 2);    return area;} // Driver codeint main(){    float a = 5;    cout << area(a) << endl;    return 0;}

## Java

 // Java Program to find the area of the square// inscribed within the circle which in turn// is inscribed in a hexagon import java.io.*; class GFG { // Function to find the area of the squarestatic float area(float a){     // side of hexagon cannot be negative    if (a < 0)        return -1;     // area of the square    float area = (float)Math.pow((a * Math.sqrt(3)) / (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

## Python3

 # Python 3 Program to find the area# of the square inscribed within the# circle which in turn is inscribed# in a hexagonfrom math import pow, sqrt # Function to find the area# of the squaredef area(a):         # side of hexagon cannot    # be negative    if (a < 0):        return -1     # area of the square    area = pow((a * sqrt(3)) /                   (sqrt(2)), 2)    return area # Driver codeif __name__ == '__main__':    a = 5    print("{0:.3}".format(area(a))) # This code is contributed# by SURENDRA_GANGWAR

## C#

 // C# Program to find the area of// the square inscribed within the// circle which in turn is inscribed// in a hexagonusing System; class GFG{ // Function to find the area// of the squarestatic float area(float a){     // side of hexagon cannot be negative    if (a < 0)        return -1;     // area of the square    float area = (float)Math.Pow((a * Math.Sqrt(3)) /                                 (Math.Sqrt(2)), 2);    return area;} // Driver codepublic static void Main (){    float a = 5;    Console.WriteLine( area(a));}} // This code is contributed by inder_verma..



## Javascript


Output:
37.5

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.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students.

My Personal Notes arrow_drop_up