# Find the Area of Pentagon

Here given code implementation process.

``````//C Program
//Find the Area of Pentagon
#include <stdio.h>

#include <math.h>
//Calculate area of pentagon by given side
void pentagon_area(double side)
{
//Calculate Formula
//¼√5(5+2√5)side²
double area = ((double) 1 / 4) * (sqrt(5 * (5 + 2 * (sqrt(5)))) * (side * side));
//Display the result of pentagon area
printf(" Pentagon  [ Side : %lf ] ", side);
printf("\n Area : %lf\n\n", area);
}
int main()
{
//Test Cases
pentagon_area(6);
pentagon_area(4);
pentagon_area(3.5);
return 0;
}``````

#### Output

`````` Pentagon  [ Side : 6.000000 ]
Area : 61.937186

Pentagon  [ Side : 4.000000 ]
Area : 27.527638

Pentagon  [ Side : 3.500000 ]
Area : 21.075848
``````
``````// Java Program
// Find the area of Pentagon
class PentagonArea
{
//Calculate area of pentagon by given side
public void pentagon_area(double side)
{
//Calculate Formula
//¼√5(5+2√5)side²
double area = ((double) 1 / 4) * (Math.sqrt(5 * (5 + 2 * (Math.sqrt(5)))) * (side * side));
//Display the result of pentagon area
System.out.print(" Pentagon [ Side : " + side + " ] ");
System.out.print("\n Area : " + area + "\n\n");
}
public static void main(String[] args)
{
PentagonArea obj = new PentagonArea();
//Test Cases
obj.pentagon_area(6);
obj.pentagon_area(4);
obj.pentagon_area(3.5);
}
}``````

#### Output

`````` Pentagon [ Side : 6.0 ]
Area : 61.93718642120281

Pentagon [ Side : 4.0 ]
Area : 27.52763840942347

Pentagon [ Side : 3.5 ]
Area : 21.075848157214846
``````
``````// C++ Program
// Find the area of Pentagon
#include<iostream>
#include <math.h>
using namespace std;
class PentagonArea
{
public:
//Calculate area of pentagon by given side
void pentagon_area(double side)
{
//Calculate Formula
//¼√5(5+2√5)side²
double area = ((double) 1 / 4) *(sqrt(5 *(5 + 2 *(sqrt(5)))) *(side *side));
cout << " Pentagon [ Side : " << side << " ] ";
cout << "\n Area : " << area << "\n\n";
}
};
int main()
{
PentagonArea obj = PentagonArea();
//Test Cases
obj.pentagon_area(6);
obj.pentagon_area(4);
obj.pentagon_area(3.5);
return 0;
}``````

#### Output

`````` Pentagon [ Side : 6 ]
Area : 61.9372

Pentagon [ Side : 4 ]
Area : 27.5276

Pentagon [ Side : 3.5 ]
Area : 21.0758
``````
``````// C# Program
// Find the area of Pentagon
using System;
class PentagonArea
{
//Calculate area of pentagon by given side
public void pentagon_area(double side)
{
//Calculate Formula
//¼√5(5+2√5)side²
double area = ((double) 1 / 4) * (Math.Sqrt(5 * (5 + 2 * (Math.Sqrt(5)))) * (side * side));
Console.Write(" Pentagon [ Side : " + side + " ] ");
Console.Write("\n Area : " + area + "\n\n");
}
public static void Main(String[] args)
{
PentagonArea obj = new PentagonArea();
//Test Cases
obj.pentagon_area(6);
obj.pentagon_area(4);
obj.pentagon_area(3.5);
}
}``````

#### Output

`````` Pentagon [ Side : 6 ]
Area : 61.9371864212028

Pentagon [ Side : 4 ]
Area : 27.5276384094235

Pentagon [ Side : 3.5 ]
Area : 21.0758481572148
``````
``````<?php
// Php Program
// Find the area of Pentagon
class PentagonArea
{
//Calculate area of pentagon by given side
public 	function pentagon_area(\$side)
{
//Calculate Formula
//¼√5(5+2√5)side²
\$area = (1 / 4) *(sqrt(5 *(5 + 2 *(sqrt(5)))) *(\$side *\$side));
//Display the result of pentagon area
echo(" Pentagon [ Side : ". \$side ." ] ");
echo("\n Area : ". \$area ."\n\n");
}
}

function main()
{
\$obj = new PentagonArea();
//Test Cases
\$obj->pentagon_area(6);
\$obj->pentagon_area(4);
\$obj->pentagon_area(3.5);
}
main();``````

#### Output

`````` Pentagon [ Side : 6 ]
Area : 61.937186421203

Pentagon [ Side : 4 ]
Area : 27.527638409423

Pentagon [ Side : 3.5 ]
Area : 21.075848157215
``````
``````// Node Js Program
// Find the area of Pentagon
class PentagonArea
{
//Calculate area of pentagon by given side
pentagon_area(side)
{
//Calculate Formula
//¼√5(5+2√5)side²
var area = (1 / 4) *(Math.sqrt(5 *(5 + 2 *(Math.sqrt(5)))) *(side *side));
//Display the result of pentagon area
process.stdout.write(" Pentagon [ Side : " + side + " ] ");
process.stdout.write("\n Area : " + area + "\n\n");
}
}

function main(args)
{
var obj = new PentagonArea();
//Test Cases
obj.pentagon_area(6);
obj.pentagon_area(4);
obj.pentagon_area(3.5);
}
main();``````

#### Output

`````` Pentagon [ Side : 6 ]
Area : 61.93718642120281

Pentagon [ Side : 4 ]
Area : 27.52763840942347

Pentagon [ Side : 3.5 ]
Area : 21.075848157214846
``````
``````#  Python 3 Program
#  Find the area of Pentagon
import math
class PentagonArea :
# Calculate area of pentagon by given side
def pentagon_area(self, side) :
# Calculate Formula
# ¼√5(5+2√5)side²
area = (1 / 4) * (math.sqrt(5 * (5 + 2 * (math.sqrt(5)))) * (side * side))
# Display the result of pentagon area
print(" Pentagon [ Side : ", side ," ] ", end = "")
print("\n Area : ", area ,"\n\n", end = "")

def main() :
obj = PentagonArea()
# Test Cases
obj.pentagon_area(6)
obj.pentagon_area(4)
obj.pentagon_area(3.5)

if __name__ == "__main__": main()``````

#### Output

`````` Pentagon [ Side :  6  ]
Area :  61.93718642120281

Pentagon [ Side :  4  ]
Area :  27.52763840942347

Pentagon [ Side :  3.5  ]
Area :  21.075848157214846
``````
``````#  Ruby Program
#  Find the area of Pentagon
class PentagonArea

# Calculate area of pentagon by given side
def pentagon_area(side)

# Calculate Formula
# ¼√5(5+2√5)side²
# 1/4 = 0.25
area = (0.25) * (Math.sqrt(5 * (5 + 2 * (Math.sqrt(5)))) * (side * side))
# Display the result of pentagon area
print(" Pentagon [ Side  : ", side ," ] ")
print("\n Area  : ", area ,"\n\n")
end
end
def main()

obj = PentagonArea.new()
# Test Cases
obj.pentagon_area(6)
obj.pentagon_area(4)
obj.pentagon_area(3.5)
end
main()``````

#### Output

`````` Pentagon [ Side  : 6 ]
Area  : 61.93718642120281

Pentagon [ Side  : 4 ]
Area  : 27.52763840942347

Pentagon [ Side  : 3.5 ]
Area  : 21.075848157214846

``````
``````// Scala Program
// Find the area of Pentagon
class PentagonArea
{
//Calculate area of pentagon by given side
def pentagon_area(side: Double): Unit = {
//Calculate Formula
//¼√5(5+2√5)side²
//1/4 = 0.25
var area: Double = (0.25) * (Math.sqrt(5 * (5 + 2 * (Math.sqrt(5)))) * (side * side));
//Display the result of pentagon area
print(" Pentagon [ Side : " + side + " ] ");
print("\n Area : " + area + "\n\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: PentagonArea = new PentagonArea();
//Test Cases
obj.pentagon_area(6);
obj.pentagon_area(4);
obj.pentagon_area(3.5);
}
}``````

#### Output

`````` Pentagon [ Side : 6.0 ]
Area : 61.93718642120281

Pentagon [ Side : 4.0 ]
Area : 27.52763840942347

Pentagon [ Side : 3.5 ]
Area : 21.075848157214846
``````
``````// Swift Program
// Find the area of Pentagon
import Foundation
class PentagonArea
{
//Calculate area of pentagon by given side
func pentagon_area(_ side: Double)
{
//Calculate Formula
//¼√5(5+2√5)side²
//1/4 = 0.25
let area: Double = (0.25) * (sqrt(5 * (5 + 2 * (sqrt(5)))) * (side * side));
//Display the result of pentagon area
print(" Pentagon [ Side : ", side ," ] ");
print(" Area : ", area ,"\n");
}
}
func main()
{
let obj: PentagonArea = PentagonArea();
//Test Cases
obj.pentagon_area(6);
obj.pentagon_area(4);
obj.pentagon_area(3.5);
}
main();``````

#### Output

`````` Pentagon [ Side :  6.0  ]
Area :  61.9371864212028

Pentagon [ Side :  4.0  ]
Area :  27.5276384094235

Pentagon [ Side :  3.5  ]
Area :  21.0758481572148
``````

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 