Program to calculate area of a Tetrahedron
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>using namespace std; //Utility Functiondouble area_of_tetrahedron(int side){ return (sqrt(3)*(side*side));}//Driver Codeint main(){ int side=3; cout<< "Area of Tetrahedron =" << area_of_tetrahedron(side);}// This code is contributed by anant321. |
Java
// Java Program to Calculate// area of tetrahedronimport java.io.*;import java.text.DecimalFormat;class GFG{// Utility Functionstatic double area_of_tetrahedron(int side){ return (double)Math.round((Math.sqrt(3) * (side * side)) * 10000d) / 10000d;}// Driver Codepublic static void main(String args[]){ int side = 3; System.out.print("Area of Tetrahedron = " + area_of_tetrahedron(side));}}// This code is contributed by// Manish Shaw(manishshaw1) |
Python 3
# Python 3 Program to Calculate# area of tetrahedronimport mathdef area_of_tetrahedron(side): return (math.sqrt(3) * (side * side))# Driver Codeside = 3;print("Area of Tetrahedron =", area_of_tetrahedron(side));# This code is contributed# by Akanksha Rai |
C#
// C# Program to Calculate// area of tetrahedronusing System;class GFG{ // Utility Function static double area_of_tetrahedron(int side) { return (Math.Sqrt(3) * (side * side)); } // Driver Code static void Main() { int side = 3; Console.Write("Area of Tetrahedron = " + area_of_tetrahedron(side)); }}// This code is contributed by// Manish Shaw(manishshaw1) |
PHP
<?php// PHP Program to Calculate// area of tetrahedronfunction area_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 ajit.?> |
Javascript
<script>// Javascript Program to Calculate// area of tetrahedron// Utility Functionfunction area_of_tetrahedron(side){ return (Math.sqrt(3) * (side * side));}// Driver Codevar side = 3;document.write("Area of Tetrahedron =" + area_of_tetrahedron(side));// This code is contributed by rutvik_56.</script> |
Output :
Area of Tetrahedron =15.5885
Another approach:
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
Java
// java program to find the volume of a tetrahedronimport java.io.*;class GFG {// Function to calculate volumestatic double vol_tetra(int side){ double volume = (Math.pow(side, 3) / (6 * Math.sqrt(2))); return volume;}// Driver Code public static void main (String[] args) { int side = 3; double vol = vol_tetra(side); System.out.println( vol); }}// This code is contributed by// anuj_67.. |
Python 3
# Python 3 program to find the volume# of a tetrahedronimport math# Function to calculate volumedef vol_tetra(side): volume = (pow(side, 3) / (6 * math.sqrt(2))) return volume;# Driver Codeif __name__ == "__main__": side = 3 vol = vol_tetra(side) print(round(vol, 2))# This code is contributed by ita_c |
C#
// C# program to find the volume// of a tetrahedronusing System;class GFG{// Function to calculate volumestatic double vol_tetra(int side){ double volume = (Math.Pow(side, 3) / (6 * Math.Sqrt(2))); return volume;}// Driver Codepublic static void Main (){ int side = 3; double vol = vol_tetra(side); Console.WriteLine( vol);}}// This code is contributed by// anuj_67.. |
PHP
<?php// PHP program to find the volume// of a tetrahedron// Function to calculate volumefunction vol_tetra($side){ $volume = (pow($side, 3) / (6 * sqrt(2))); return $volume;}// Driver Code$side = 3;$vol = vol_tetra($side);echo $vol;// This code is contributed// by Ankita Saini?> |
Javascript
<script> // Javascript program to find the volume // of a tetrahedron // Function to calculate volume function vol_tetra(side) { var volume = parseInt((Math.pow(side, 3) / (6 * Math.sqrt(2)))); return volume; } // Driver Code var side = 3; var vol = vol_tetra(side); document.write(vol);// This code is contributed by noob2000. </script> |
Output :
3.18
Please refer complete article on Program to calculate area and volume of a Tetrahedron for more details!
Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.



