# Find surface area of octahedron

An octahedron is a three-dimensional geometric shape with eight equilateral triangular faces. Finding the surface area of an octahedron involves calculating the total area of all its triangular faces. This calculation is important in geometry, architecture, and various engineering applications where octahedra are used to model certain structures and components.

## Problem Statement

Given the length of a side (a) of the octahedron, the task is to calculate its surface area. The formula for finding the surface area of an octahedron in terms of its side length 'a' is:

Surface Area = 2 * √(3) * a²

## Example Scenario

Suppose you are an architect designing a pavilion with a unique shape composed of octahedra. To estimate the amount of material needed to cover the structure, you need to calculate the surface area of each octahedron. This calculation helps ensure you have accurate cost estimates and materials planning.

## Idea to Solve the Problem

To solve this problem, we can follow these steps:

- Accept the side length 'a' of the octahedron as an input.
- Use the formula to calculate the surface area of the octahedron.
- Display the calculated surface area.

## Pseudocode

```
function octahedron_surface_area(a):
area = 2 * √(3) * a²
return area
main:
a1 = 4.8
a2 = 5
a3 = 6.2
area1 = octahedron_surface_area(a1)
area2 = octahedron_surface_area(a2)
area3 = octahedron_surface_area(a3)
print("Octahedron [ Side :", a1, "]")
print("Surface Area :", area1)
print("Octahedron [ Side :", a2, "]")
print("Surface Area :", area2)
print("Octahedron [ Side :", a3, "]")
print("Surface Area :", area3)
```

## Algorithm Explanation

- Define a function
`octahedron_surface_area`

that takes the side length 'a' as an input. - Inside the function, use the provided formula to calculate the surface area of the octahedron.
- In the
`main`

function, set three test cases with different side lengths 'a'. - Calculate the surface areas for each test case by calling the
`octahedron_surface_area`

function. - Display the calculated surface areas along with their respective side length values.

## Code Solution

```
/*
C Program
Find surface area of octahedron
*/
#include <stdio.h>
#include <math.h>
//Calculate surface area of octahedron by side
void surface_area(double side)
{
// Formula of octahedron surface area
// 2 √(3) side²
printf("\nGiven Side : %lf", side);
//Calculate surface of octahedron
double area = 2 * sqrt(3) * (side * side);
printf("\nSurface area of octahedron : %lf\n", area);
}
int main()
{
//Simple Case
surface_area(4.8);
surface_area(5);
surface_area(6.2);
return 0;
}
```

#### Output

```
Given Side : 4.800000
Surface area of octahedron : 79.812901
Given Side : 5.000000
Surface area of octahedron : 86.602540
Given Side : 6.200000
Surface area of octahedron : 133.160066
```

```
// Java Program
// Find surface area of octahedron
class Octahedron
{
//Calculate surface area of octahedron by side
public void surface_area(double side)
{
// Formula of octahedron surface area
// 2 √(3) side²
System.out.print("\nGiven Side : " + side);
//Calculate surface of octahedron
double area = 2 * Math.sqrt(3) * (side * side);
System.out.print("\nSurface area of octahedron : " + area + "\n");
}
public static void main(String[] args)
{
Octahedron obj = new Octahedron();
//Simple Case
obj.surface_area(4.8);
obj.surface_area(5);
obj.surface_area(6.2);
}
}
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.81290121277385
Given Side : 5.0
Surface area of octahedron : 86.60254037844386
Given Side : 6.2
Surface area of octahedron : 133.1600660858953
```

```
// C++ Program
// Find surface area of octahedron
#include<iostream>
#include<math.h>
using namespace std;
class Octahedron
{
public:
//Calculate surface area of octahedron by side
void surface_area(double side)
{
// Formula of octahedron surface area
// 2 √(3) side²
cout << "\nGiven Side : " << side;
//Calculate surface of octahedron
double area = 2 * sqrt(3) * (side * side);
cout << "\nSurface area of octahedron : " << area << "\n";
}
};
int main()
{
Octahedron obj;
//Simple Case
obj.surface_area(4.8);
obj.surface_area(5);
obj.surface_area(6.2);
return 0;
}
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.8129
Given Side : 5
Surface area of octahedron : 86.6025
Given Side : 6.2
Surface area of octahedron : 133.16
```

```
// C# Program
// Find surface area of octahedron
using System;
class Octahedron
{
//Calculate surface area of octahedron by side
public void surface_area(double side)
{
Console.Write("\nGiven Side : " + side);
// Formula of octahedron surface area
// 2 √(3) side²
//Calculate surface of octahedron
double area = 2 * Math.Sqrt(3) * (side * side);
Console.Write("\nSurface area of octahedron : " + area + "\n");
}
public static void Main(String[] args)
{
Octahedron obj = new Octahedron();
//Simple Case
obj.surface_area(4.8);
obj.surface_area(5);
obj.surface_area(6.2);
}
}
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.8129012127739
Given Side : 5
Surface area of octahedron : 86.6025403784439
Given Side : 6.2
Surface area of octahedron : 133.160066085895
```

```
<?php
// Php Program
// Find surface area of octahedron
class Octahedron
{
//Calculate surface area of octahedron by side
public function surface_area($side)
{
echo "\nGiven Side : ". $side;
// Formula of octahedron surface area
// 2 √(3) side²
//Calculate surface of octahedron
$area = 2 * sqrt(3) * ($side * $side);
echo "\nSurface area of octahedron : ". $area ."\n";
}
}
function main()
{
$obj = new Octahedron();
//Simple Case
$obj->surface_area(4.8);
$obj->surface_area(5);
$obj->surface_area(6.2);
}
main();
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.812901212774
Given Side : 5
Surface area of octahedron : 86.602540378444
Given Side : 6.2
Surface area of octahedron : 133.1600660859
```

```
// Node Js Program
// Find surface area of octahedron
class Octahedron
{
//Calculate surface area of octahedron by side
surface_area(side)
{
process.stdout.write("\nGiven Side : " + side);
// Formula of octahedron surface area
// 2 √(3) side²
//Calculate surface of octahedron
var area = 2 * Math.sqrt(3) * (side * side);
process.stdout.write("\nSurface area of octahedron : " + area + "\n");
}
}
function main()
{
var obj = new Octahedron();
//Simple Case
obj.surface_area(4.8);
obj.surface_area(5);
obj.surface_area(6.2);
}
main();
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.81290121277385
Given Side : 5
Surface area of octahedron : 86.60254037844386
Given Side : 6.2
Surface area of octahedron : 133.1600660858953
```

```
# Python 3 Program
# Find surface area of octahedron
import math
class Octahedron :
# Calculate surface area of octahedron by side
def surface_area(self, side) :
print("\nGiven Side : ", side, end = "")
# Formula of octahedron surface area
# 2 √(3) side²
# Calculate surface of octahedron
area = 2 * math.sqrt(3) * (side * side)
print("\nSurface area of octahedron : ", area ,"\n", end = "")
def main() :
obj = Octahedron()
# Simple Case
obj.surface_area(4.8)
obj.surface_area(5)
obj.surface_area(6.2)
if __name__ == "__main__": main()
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.81290121277385
Given Side : 5
Surface area of octahedron : 86.60254037844386
Given Side : 6.2
Surface area of octahedron : 133.1600660858953
```

```
# Ruby Program
# Find surface area of octahedron
class Octahedron
# Calculate surface area of octahedron by side
def surface_area(side)
print("\nGiven Side : ", side)
# Formula of octahedron surface area
# 2 √(3) side²
# Calculate surface of octahedron
area = 2 * Math.sqrt(3) * (side * side)
print("\nSurface area of octahedron : ", area ,"\n")
end
end
def main()
obj = Octahedron.new()
# Simple Case
obj.surface_area(4.8)
obj.surface_area(5)
obj.surface_area(6.2)
end
main()
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.81290121277385
Given Side : 5
Surface area of octahedron : 86.60254037844386
Given Side : 6.2
Surface area of octahedron : 133.1600660858953
```

```
// Scala Program
// Find surface area of octahedron
class Octahedron
{
//Calculate surface area of octahedron by side
def surface_area(side: Double): Unit = {
print("\nGiven Side : " + side);
// Formula of octahedron surface area
// 2 √(3) side²
//Calculate surface of octahedron
var area: Double = 2 * Math.sqrt(3) * (side * side);
print("\nSurface area of octahedron : " + area + "\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: Octahedron = new Octahedron();
//Simple Case
obj.surface_area(4.8);
obj.surface_area(5);
obj.surface_area(6.2);
}
}
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.81290121277385
Given Side : 5.0
Surface area of octahedron : 86.60254037844386
Given Side : 6.2
Surface area of octahedron : 133.1600660858953
```

```
// Swift Program
// Find surface area of octahedron
import Foundation
class Octahedron
{
//Calculate surface area of octahedron by side
func surface_area(_ side: Double)
{
print("\nGiven Side : ", side, terminator: "");
// Formula of octahedron surface area
// 2 √(3) side²
//Calculate surface of octahedron
let area: Double = 2 * sqrt(3) * (side * side);
print("\nSurface area of octahedron : ", area ,"\n", terminator: "");
}
}
func main()
{
let obj: Octahedron = Octahedron();
//Simple Case
obj.surface_area(4.8);
obj.surface_area(5);
obj.surface_area(6.2);
}
main();
```

#### Output

```
Given Side : 4.8
Surface area of octahedron : 79.8129012127739
Given Side : 5.0
Surface area of octahedron : 86.6025403784439
Given Side : 6.2
Surface area of octahedron : 133.160066085895
```

## Output Explanation

The code calculates the surface area for each test case and displays the results. For an octahedron with a side length 'a' = 4.8, the surface area is approximately 79.812901. Similarly, for side lengths 'a' = 5 and 'a' = 6.2, the surface areas are approximately 86.602540 and 133.160066, respectively.

## Time Complexity

The time complexity of this code is constant O(1) because the calculations involve basic arithmetic operations and the use of square roots, which are computed in constant time regardless of the input size. The program performs a fixed number of operations for each test case, making it efficient.

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