A Tetrahedron is simply a pyramid with a triangular base. It is a solid object with four triangular faces, three on the sides or lateral faces, one on the bottom or the base and four vertices or corners. If the faces are all congruent equilateral triangles, then the tetrahedron is called regular.
The area of Tetrahedron can be found by using the formula :
Area = sqrt(3)*(side*side)
Examples :
Input : side = 3
Output : 15.5885
Input : side = 20
Output : 692.82
C++
// C++ Program to Calculate
// area of tetrahedron
#include<iostream>
#include<math.h>
usingnamespacestd;
//Utility Function
doublearea_of_tetrahedron(intside)
{
return(sqrt(3)*(side*side));
}
//Driver Code
intmain()
{
intside=3;
cout<< "Area of Tetrahedron ="
<< area_of_tetrahedron(side);
}
// This code is contributed by anant321.
Java
// Java Program to Calculate
// area of tetrahedron
importjava.util.*;
importjava.lang.*;
classGFG {
// Utility Function
publicstaticdoublearea_of_tetrahedron(intside)
{
return(Math.sqrt(3) * (side * side));
}
// Driver code
publicstaticvoidmain(String[] args)
{
intside = 3;
System.out.println("Area of Tetrahedron ="
+ area_of_tetrahedron(side));
}
}
// This code is contributed
// by Prasad Kshirsagar
Python3
# Python3 Program to
# Calculate area of
# tetrahedron
importmath
defarea_of_tetrahedron(side):
return(math.sqrt(3) *
(side *side));
# Driver Code
side =3;
print("Area of Tetrahedron = ",
round(area_of_tetrahedron(side), 4));
# This code is contributed by mits
C#
// C# Program to Calculate
// area of tetrahedron
usingSystem;
classGFG
{
// Utility Function
publicstaticdoublearea_of_tetrahedron(intside)
{
return(Math.Sqrt(3) *
(side * side));
}
// Driver code
staticpublicvoidMain ()
{
intside = 3;
Console.WriteLine("Area of Tetrahedron = "+
area_of_tetrahedron(side));
}
}
// This code is contributed
// by akt_mit
PHP
<?php
// PHP Program to Calculate
// area of tetrahedron
functionarea_of_tetrahedron($side)
{
return(sqrt(3) * ($side* $side));
}
// Driver Code
$side= 3;
echo"Area of Tetrahedron = ",
area_of_tetrahedron($side);
// This code is contributed by aj_36.
?>
Javascript
<script>
// javascript Program to Calculate
// area of tetrahedron
// Utility Function
functionarea_of_tetrahedron( side)
{
return(Math.sqrt(3) * (side * side));
}
// Driver Code
let side = 3;
document.write("Area of Tetrahedron ="
+ area_of_tetrahedron(side).toFixed(4));
// This code contributed by aashish1995
</script
Output
Area of Tetrahedron =15.5885
Time complexity: O(1) as it is performing constant operations Auxiliary space: O(1)
The volume of the tetrahedron can be found by using the following formula :
Volume = a3/(6?2)
Examples :
Input : side = 3
Output : 3.18
Input : side = 20
Output : 942.81
Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!
… [Trackback]
[…] Read More here on that Topic: geeksforgeeks.org/program-to-calculate-area-and-volume-of-a-tetrahedron/ […]
… [Trackback]
[…] Info on that Topic: geeksforgeeks.org/program-to-calculate-area-and-volume-of-a-tetrahedron/ […]
… [Trackback]
[…] Find More here to that Topic: geeksforgeeks.org/program-to-calculate-area-and-volume-of-a-tetrahedron/ […]