# Calculate area of equilateral triangle

Here given code implementation process.

``````//C Program
//Calculate area of equilateral triangle
#include <stdio.h>
#include <math.h>

///Calculate area of equilateral triangle by given side
void equilateral_triangle(double side)
{
//Calculate area of equilateral triangle
double area = (sqrt(3) / 4) * (side * side);
//Display the result of right angle triangle area
printf(" Equilateral triangle  [ side : %lf ] ", side);
printf("\n Area : %lf\n\n", area);
}
int main()
{
//Test Cases
equilateral_triangle(5);
equilateral_triangle(10);
equilateral_triangle(7.5);
return 0;
}``````

#### Output

`````` Equilateral triangle  [ side : 5.000000 ]
Area : 10.825318

Equilateral triangle  [ side : 10.000000 ]
Area : 43.301270

Equilateral triangle  [ side : 7.500000 ]
Area : 24.356964
``````
``````// Java Program
// Calculate area of equilateral triangle
class EquilateralTriangle
{
//Calculate area of equilateral triangle by given side
public void equilateral_triangle(double side)
{
//Calculate area of equilateral triangle
double area = (Math.sqrt(3) / 4) * (side * side);
//Display the result of right angle triangle area
System.out.print(" Equilateral triangle [ side : " + side + " ] ");
System.out.print("\n Area : " + area + "\n\n");
}
public static void main(String[] args)
{
EquilateralTriangle obj = new EquilateralTriangle();
//Test Cases
obj.equilateral_triangle(5);
obj.equilateral_triangle(10);
obj.equilateral_triangle(7.5);
}
}``````

#### Output

`````` Equilateral triangle [ side : 5.0 ]
Area : 10.825317547305483

Equilateral triangle [ side : 10.0 ]
Area : 43.30127018922193

Equilateral triangle [ side : 7.5 ]
Area : 24.356964481437334
``````
``````// C++ Program
// Calculate area of equilateral triangle
#include<iostream>
#include <math.h>
using namespace std;
class EquilateralTriangle
{
public:
//Calculate area of equilateral triangle by given side
void equilateral_triangle(double side)
{
//Calculate area of equilateral triangle
double area = (sqrt(3) / 4) *(side *side);
cout << " Equilateral triangle [ side : " << side << " ] ";
cout << "\n Area : " << area << "\n\n";
}
};
int main()
{
EquilateralTriangle obj =  EquilateralTriangle();
//Test Cases
obj.equilateral_triangle(5);
obj.equilateral_triangle(10);
obj.equilateral_triangle(7.5);
return 0;
}``````

#### Output

`````` Equilateral triangle [ side : 5 ]
Area : 10.8253

Equilateral triangle [ side : 10 ]
Area : 43.3013

Equilateral triangle [ side : 7.5 ]
Area : 24.357
``````
``````// C# Program
// Calculate area of equilateral triangle
using System;
class EquilateralTriangle
{
//Calculate area of equilateral triangle by given side
public void equilateral_triangle(double side)
{
//Calculate area of equilateral triangle
double area = (Math.Sqrt(3) / 4) * (side * side);
Console.Write(" Equilateral triangle [ side : " + side + " ] ");
Console.Write("\n Area : " + area + "\n\n");
}
public static void Main(String[] args)
{
EquilateralTriangle obj = new EquilateralTriangle();
//Test Cases
obj.equilateral_triangle(5);
obj.equilateral_triangle(10);
obj.equilateral_triangle(7.5);
}
}``````

#### Output

`````` Equilateral triangle [ side : 5 ]
Area : 10.8253175473055

Equilateral triangle [ side : 10 ]
Area : 43.3012701892219

Equilateral triangle [ side : 7.5 ]
Area : 24.3569644814373
``````
``````<?php
// Php Program
// Calculate area of equilateral triangle
class EquilateralTriangle
{
//Calculate area of equilateral triangle by given side
public 	function equilateral_triangle(\$side)
{
//Calculate area of equilateral triangle
\$area = (sqrt(3) / 4) *(\$side *\$side);
//Display the result of right angle triangle area
echo(" Equilateral triangle [ side : ". \$side ." ] ");
echo("\n Area : ". \$area ."\n\n");
}
}

function main()
{
\$obj = new EquilateralTriangle();
//Test Cases
\$obj->equilateral_triangle(5);
\$obj->equilateral_triangle(10);
\$obj->equilateral_triangle(7.5);
}
main();``````

#### Output

`````` Equilateral triangle [ side : 5 ]
Area : 10.825317547305

Equilateral triangle [ side : 10 ]
Area : 43.301270189222

Equilateral triangle [ side : 7.5 ]
Area : 24.356964481437
``````
``````// Node Js Program
// Calculate area of equilateral triangle
class EquilateralTriangle
{
//Calculate area of equilateral triangle by given side
equilateral_triangle(side)
{
//Calculate area of equilateral triangle
var area = (Math.sqrt(3) / 4) *(side *side);
//Display the result of right angle triangle area
process.stdout.write(" Equilateral triangle [ side : " + side + " ] ");
process.stdout.write("\n Area : " + area + "\n\n");
}
}

function main(args)
{
var obj = new EquilateralTriangle();
//Test Cases
obj.equilateral_triangle(5);
obj.equilateral_triangle(10);
obj.equilateral_triangle(7.5);
}
main();``````

#### Output

`````` Equilateral triangle [ side : 5 ]
Area : 10.825317547305483

Equilateral triangle [ side : 10 ]
Area : 43.30127018922193

Equilateral triangle [ side : 7.5 ]
Area : 24.356964481437334
``````
``````#  Python 3 Program
#  Calculate area of equilateral triangle
import math
class EquilateralTriangle :
# Calculate area of equilateral triangle by given side
def equilateral_triangle(self, side) :
# Calculate area of equilateral triangle
area = (math.sqrt(3) / 4) * (side * side)
# Display the result of right angle triangle area
print(" Equilateral triangle [ side : ", side , end = " ] ")
print("\n Area : ", area ,"\n")

def main() :
obj = EquilateralTriangle()
# Test Cases
obj.equilateral_triangle(5)
obj.equilateral_triangle(10)
obj.equilateral_triangle(7.5)

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

#### Output

`````` Equilateral triangle [ side :  5 ]
Area :  10.825317547305483

Equilateral triangle [ side :  10 ]
Area :  43.30127018922193

Equilateral triangle [ side :  7.5 ]
Area :  24.356964481437334
``````
``````#  Ruby Program
#  Calculate area of equilateral triangle
class EquilateralTriangle

# Calculate area of equilateral triangle by given side
def equilateral_triangle(side)

# Calculate area of equilateral triangle
area = (Math.sqrt(3) / 4) * (side * side)
# Display the result of right angle triangle area
print(" Equilateral triangle [ side  : ", side ," ] ")
print("\n Area  : ", area ,"\n\n")
end
end
def main()

obj = EquilateralTriangle.new()
# Test Cases
obj.equilateral_triangle(5)
obj.equilateral_triangle(10)
obj.equilateral_triangle(7.5)
end
main()``````

#### Output

`````` Equilateral triangle [ side  : 5 ]
Area  : 10.825317547305483

Equilateral triangle [ side  : 10 ]
Area  : 43.30127018922193

Equilateral triangle [ side  : 7.5 ]
Area  : 24.356964481437334

``````
``````// Scala Program
// Calculate area of equilateral triangle
class EquilateralTriangle
{
//Calculate area of equilateral triangle by given side
def equilateral_triangle(side: Double): Unit = {
//Calculate area of equilateral triangle
var area: Double = ((Math.sqrt(3) / 4)) * (side * side);
//Display the result of right angle triangle area
print(" Equilateral triangle [ side : " + side + " ] ");
print("\n Area : " + area + "\n\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: EquilateralTriangle = new EquilateralTriangle();
//Test Cases
obj.equilateral_triangle(5);
obj.equilateral_triangle(10);
obj.equilateral_triangle(7.5);
}
}``````

#### Output

`````` Equilateral triangle [ side : 5.0 ]
Area : 10.825317547305483

Equilateral triangle [ side : 10.0 ]
Area : 43.30127018922193

Equilateral triangle [ side : 7.5 ]
Area : 24.356964481437334
``````
``````// Swift Program
// Calculate area of equilateral triangle
import Foundation
class EquilateralTriangle
{
//Calculate area of equilateral triangle by given side
func equilateral_triangle(_ side: Double)
{
//Calculate area of equilateral triangle
let area: Double = (sqrt(3) / 4) * (side * side);
//Display the result of right angle triangle area
print(" Equilateral triangle [ side : ", side ,"]");
print(" Area : ", area ,"\n");
}
}
func main()
{
let obj: EquilateralTriangle = EquilateralTriangle();
//Test Cases
obj.equilateral_triangle(5);
obj.equilateral_triangle(10);
obj.equilateral_triangle(7.5);
}
main();``````

#### Output

`````` Equilateral triangle [ side :  5.0 ]
Area :  10.8253175473055

Equilateral triangle [ side :  10.0 ]
Area :  43.3012701892219

Equilateral triangle [ side :  7.5 ]
Area :  24.3569644814373
``````

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 