# Find the area of a Hexagon

To find the area of a hexagon, you need to know the length of one of its sides, which we can denote as s.

Then, you can use the following formula:

Area of hexagon = (3√3/2) x s²

where 3√3/2 is a constant value equal to approximately 2.598.

So, if you have the length of one side of the hexagon, you can plug it into the formula to find the area. For example, if s = 5 cm, the area would be:

Area of hexagon = (3√3/2) x 5² = (3√3/2) x 25 = 32.475 cm²

Therefore, the area of a hexagon with a side length of 5 cm is approximately 32.475 cm².

Here given code implementation process.

```
/*
C Program
Find the area of a Hexagon
*/
#include <stdio.h>
#include <math.h>
//Calculate area of hexagon by given side length
void hexagon_area(double side)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
double area = (3 * sqrt(3) * (side * side)) / 2;
//Display result
printf("Hexagon Area of side %lf is : %lf\n", side, area);
}
int main()
{
//Test Case
hexagon_area(7);
hexagon_area(3);
hexagon_area(5.2);
return 0;
}
```

#### Output

```
Hexagon Area of side 7.000000 is : 127.305734
Hexagon Area of side 3.000000 is : 23.382686
Hexagon Area of side 5.200000 is : 70.251981
```

```
// Java Program
// Find the area of a Hexagon
class Hexagon
{
//Calculate area of hexagon by given side length
public void hexagon_area(double side)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
double area = (3 * Math.sqrt(3) * (side * side)) / 2;
System.out.print("Hexagon Area of side " + side + " is : " + area + "\n");
}
public static void main(String[] args)
{
Hexagon obj = new Hexagon();
//Simple Case
obj.hexagon_area(7);
obj.hexagon_area(3);
obj.hexagon_area(5.2);
}
}
```

#### Output

```
Hexagon Area of side 7.0 is : 127.30573435631248
Hexagon Area of side 3.0 is : 23.382685902179844
Hexagon Area of side 5.2 is : 70.25198075499367
```

```
// C++ Program
// Find the area of a Hexagon
#include<iostream>
#include<math.h>
using namespace std;
class Hexagon
{
public:
//Calculate area of hexagon by given side length
void hexagon_area(double side)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
double area = (3 * sqrt(3) * (side * side)) / 2;
cout << "Hexagon Area of side " << side << " is : " << area << "\n";
}
};
int main()
{
Hexagon obj = Hexagon();
//Simple Case
obj.hexagon_area(7);
obj.hexagon_area(3);
obj.hexagon_area(5.2);
return 0;
}
```

#### Output

```
Hexagon Area of side 7 is : 127.306
Hexagon Area of side 3 is : 23.3827
Hexagon Area of side 5.2 is : 70.252
```

```
// C# Program
// Find the area of a Hexagon
using System;
class Hexagon
{
//Calculate area of hexagon by given side length
public void hexagon_area(double side)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
double area = (3 * Math.Sqrt(3) * (side * side)) / 2;
Console.Write("Hexagon Area of side " + side + " is : " + area + "\n");
}
public static void Main(String[] args)
{
Hexagon obj = new Hexagon();
//Simple Case
obj.hexagon_area(7);
obj.hexagon_area(3);
obj.hexagon_area(5.2);
}
}
```

#### Output

```
Hexagon Area of side 7 is : 127.305734356312
Hexagon Area of side 3 is : 23.3826859021798
Hexagon Area of side 5.2 is : 70.2519807549937
```

```
<?php
// Php Program
// Find the area of a Hexagon
class Hexagon
{
//Calculate area of hexagon by given side length
public function hexagon_area($side)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
$area = (3 * sqrt(3) * ($side * $side)) / 2;
echo "Hexagon Area of side ". $side ." is : ". $area ."\n";
}
}
function main()
{
$obj = new Hexagon();
//Simple Case
$obj->hexagon_area(7);
$obj->hexagon_area(3);
$obj->hexagon_area(5.2);
}
main();
```

#### Output

```
Hexagon Area of side 7 is : 127.30573435631
Hexagon Area of side 3 is : 23.38268590218
Hexagon Area of side 5.2 is : 70.251980754994
```

```
// Node Js Program
// Find the area of a Hexagon
class Hexagon
{
//Calculate area of hexagon by given side length
hexagon_area(side)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
var area = (3 * Math.sqrt(3) * (side * side)) / 2;
process.stdout.write("Hexagon Area of side " + side + " is : " + area + "\n");
}
}
function main()
{
var obj = new Hexagon();
//Simple Case
obj.hexagon_area(7);
obj.hexagon_area(3);
obj.hexagon_area(5.2);
}
main();
```

#### Output

```
Hexagon Area of side 7 is : 127.30573435631248
Hexagon Area of side 3 is : 23.382685902179844
Hexagon Area of side 5.2 is : 70.25198075499367
```

```
# Python 3 Program
# Find the area of a Hexagon
import math
class Hexagon :
# Calculate area of hexagon by given side length
def hexagon_area(self, side) :
# Formula of hexagon area
# (3 √3(side)² ) / 2
# Calculate area of hexagon
area = (3 * math.sqrt(3) * (side * side)) / 2
print("Hexagon Area of side ", side ," is : ", area ,"\n", end = "")
def main() :
obj = Hexagon()
# Simple Case
obj.hexagon_area(7)
obj.hexagon_area(3)
obj.hexagon_area(5.2)
if __name__ == "__main__": main()
```

#### Output

```
Hexagon Area of side 7 is : 127.30573435631248
Hexagon Area of side 3 is : 23.382685902179844
Hexagon Area of side 5.2 is : 70.25198075499367
```

```
# Ruby Program
# Find the area of a Hexagon
class Hexagon
# Calculate area of hexagon by given side length
def hexagon_area(side)
# Formula of hexagon area
# (3 √3(side)² ) / 2
# Calculate area of hexagon
area = (3 * Math.sqrt(3) * (side * side)) / 2
print("Hexagon Area of side ", side ," is : ", area ,"\n")
end
end
def main()
obj = Hexagon.new()
# Simple Case
obj.hexagon_area(7)
obj.hexagon_area(3)
obj.hexagon_area(5.2)
end
main()
```

#### Output

```
Hexagon Area of side 7 is : 127.30573435631248
Hexagon Area of side 3 is : 23.382685902179844
Hexagon Area of side 5.2 is : 70.25198075499367
```

```
// Scala Program
// Find the area of a Hexagon
class Hexagon
{
//Calculate area of hexagon by given side length
def hexagon_area(side: Double): Unit = {
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
var area: Double = (3 * Math.sqrt(3) * (side * side)) / 2;
print("Hexagon Area of side " + side + " is : " + area + "\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: Hexagon = new Hexagon();
//Simple Case
obj.hexagon_area(7);
obj.hexagon_area(3);
obj.hexagon_area(5.2);
}
}
```

#### Output

```
Hexagon Area of side 7.0 is : 127.30573435631248
Hexagon Area of side 3.0 is : 23.382685902179844
Hexagon Area of side 5.2 is : 70.25198075499367
```

```
// Swift Program
// Find the area of a Hexagon
import Foundation
class Hexagon
{
//Calculate area of hexagon by given side length
func hexagon_area(_ side: Double)
{
// Formula of hexagon area
// (3 √3(side)² ) / 2
// Calculate area of hexagon
let area: Double = (3 * sqrt(3) * (side * side)) / 2;
print("Hexagon Area of side ", side ," is : ", area ,"\n", terminator: "");
}
}
func main()
{
let obj: Hexagon = Hexagon();
//Simple Case
obj.hexagon_area(7);
obj.hexagon_area(3);
obj.hexagon_area(5.2);
}
main();
```

#### Output

```
Hexagon Area of side 7.0 is : 127.305734356312
Hexagon Area of side 3.0 is : 23.3826859021798
Hexagon Area of side 5.2 is : 70.2519807549937
```

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

## New Comment