Program to find the Area and Volume of Icosahedron
Given the side of an Icosahedron. The task is to find the area and volume of the given Icosahedron.
Examples :
Input : a = 5
Output : Area: 216.506
Volume: 272.712
Input : a = 10
Output : Area: 866.0254
Volume: 2181.695
In geometry, an Icosahedron is a regular polyhedron which contains 20 identical equilateral triangular faces, 30 sides, and 12 vertices.
Formula to find Area and Volume of Icosahedron: Let a be the side of Icosahedron, then
Surface area of Icosahedron =
and, Volume of Icosahedron =
C++
#include <bits/stdc++.h>
using namespace std;
float findArea( float a)
{
float area;
area = 5 * sqrt (3) * a * a;
return area;
}
float findVolume( float a)
{
float volume;
volume = (( float )5 / 12) * (3 + sqrt (5)) * a * a * a;
return volume;
}
int main()
{
float a = 5;
cout << "Area: " << findArea(a) << endl;
cout << "Volume: " << findVolume(a);
return 0;
}
|
Java
import java.io.*;
class GFG {
static float findArea( float a)
{
float area;
area = ( float )( 5 * Math.sqrt( 3 ) * a * a);
return area;
}
static float findVolume( float a)
{
float volume;
volume = ( float )((( float ) 5 / 12 ) * ( 3 + Math.sqrt( 5 )) * a * a * a);
return volume;
}
public static void main (String[] args)
{
float a = 5 ;
System.out.println( "Area: " + findArea(a));
System.out.println( "Volume: " + findVolume(a));
}
}
|
Python3
from math import sqrt
def findArea(a):
area = 5 * sqrt( 3 ) * a * a
return area
def findVolume(a):
volume = (( 5 / 12 ) *
( 3 + sqrt( 5 )) *
a * a * a)
return volume
a = 5
print ( "Area: " , findArea(a))
print ( "Volume: " , findVolume(a))
|
C#
using System;
public class GFG {
static float findArea( float a)
{
float area;
area = ( float )(5 * Math.Sqrt(3) * a * a);
return area;
}
static float findVolume( float a)
{
float volume;
volume = ( float )((( float )5 / 12) * (3 + Math.Sqrt(5)) * a * a * a);
return volume;
}
static public void Main ()
{
float a = 5;
Console.WriteLine( "Area: " + findArea(a));
Console.WriteLine( "Volume: " + findVolume(a));
}
}
|
PHP
<?php
function findArea( $a )
{
$area ;
$area = 5 * sqrt(3) *
$a * $a ;
return $area ;
}
function findVolume( $a )
{
$volume ;
$volume = ((float)5 / 12) *
(3 + sqrt(5)) *
$a * $a * $a ;
return $volume ;
}
$a = 5;
echo "Area: " , findArea( $a ), "\n" ;
echo "Volume: " , findVolume( $a );
?>
|
Javascript
<script>
function findArea( a)
{
let area;
area = 5 * Math.sqrt(3) * a * a;
return area;
}
function findVolume( a)
{
let volume;
volume = (5 / 12) * (3 + Math.sqrt(5)) * a * a * a;
return volume;
}
let a = 5;
document.write( "Area: " + findArea(a).toFixed(3) + "<br/>" );
document.write( "Volume: " + findVolume(a).toFixed(3));
</script>
|
Output: Area: 216.506
Volume: 272.712
Time Complexity: O(1)
Auxiliary Space: O(1)
Last Updated :
09 Jun, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...