Program for Surface area of Dodecahedron
Last Updated :
20 Feb, 2023
Given the edge of the dodecahedron calculate its surface area. Surface area is the amount of space that all the faces of the shape take up.
Formula:
Examples:
Input: 3
Output: 185.812
Input: 7
Output: 1011.64
A dodecahedron is a 3-dimensional figure made up of 12 faces, or flat sides. All of the faces are pentagons of the same size. The word ‘dodecahedron’ comes from the Greek words dodeca (‘twelve’) and hedron (‘faces’). Every shape has properties and characteristics. So has dodecahedron
- 12 equal pentagonal faces
- 20 vertices
- 30 edges
where pentagon is a 2-dimensional shape with 5 straight sides and 5 vertices. So, a dodecahedron has 12 of these flat, equal pentagonal faces. So one can think of dodecahedron as a 12 faced dice(Usually not seen) but can be in a Battleball board game.
C++
#include <bits/stdc++.h>
using namespace std;
double area_of_dodecahedron( int side)
{
return ((3 * sqrt (25 + 10 * ( sqrt (5))))
* ( pow (side, 2))) ;
}
int main()
{
int side = 3;
cout<< "Surface area of dodecahedron = "
<< area_of_dodecahedron(side);
return 0;
}
|
Java
class GFG
{
static double area_of_dodecahedron( int side)
{
return (( 3 * Math.sqrt( 25 + 10 * (Math.sqrt( 5 ))))
* (Math.pow(side, 2 ))) ;
}
public static void main (String[] args)
{
int side = 3 ;
System.out.println( "Surface area of dodecahedron ="
+ area_of_dodecahedron(side));
}
}
|
Python3
import math
def area_of_dodecahedron(side):
return (( 3 * math.sqrt( 25 + 10 * (math.sqrt( 5 )))) * (math. pow (side, 2 )))
side = 3
print ( "Surface area of dodecahedron = " ,
round (area_of_dodecahedron(side), 3 ))
|
C#
using System;
class GFG
{
static float area_of_dodecahedron( int side)
{
return ( float )((3 * Math.Sqrt(25 + 10 * (Math.Sqrt(5))))
* (Math.Pow(side, 2))) ;
}
public static void Main ()
{
int side = 3;
Console.WriteLine( "Surface area of dodecahedron ="
+ area_of_dodecahedron(side));
}
}
|
PHP
<?php
function area_of_dodecahedron( $side )
{
return ((3 * sqrt(25 + 10 * (sqrt(5))))
* (pow( $side , 2))) ;
}
$side = 3;
echo ( "Surface area of dodecahedron = " );
echo (area_of_dodecahedron( $side ));
?>
|
Javascript
<script>
function area_of_dodecahedron( side)
{
return ((3 * Math.sqrt(25 + 10 * (Math.sqrt(5))))
* (Math.pow(side, 2))) ;
}
let side = 3;
document.write( "Surface area of dodecahedron = "
+ Math.round(area_of_dodecahedron(side)*1000)/1000);
</script>
|
OutputSurface area of dodecahedron = 185.812
Time complexity: O(log(side)) where side is given input, since using in-built sqrt() function
Auxiliary space: O(1) because it is using constant variables
Share your thoughts in the comments
Please Login to comment...