Q:

Write a program to find the Area of Tetrahedron

belongs to collection: Miscellaneous Programs Examples

0

Before writing the program of calculating the area of a tetrahedron in different programming languages, firstly we have to know about what is tetrahedron and its formula.

What is Tetrahedron?

Tetrahedron is simply a polyhedron shape, which has 4 triangular faces, four vertices, and six edges. If the faces are all congruent equilateral triangles, then the tetrahedron is called regular.

Area of Tetrahedron

 

Area of Tetrahedron = (√3 * ( a * a ))  

where, a is the side of an tetrahedron.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program of calculating the area of a tetrahedron in different Programming languages

Program 1: Write a Program in C language:

// This program which uses a function to find the area of a tetrahedron.  
#include <stdio.h>  
float find_area_of_tetrahedron(float a) // It is a function to find area   
{   
float area_of_tetrahedron;  
area_of_tetrahedron= ( sqrt(3) * ( a * a )); // It is a formula for calculating the area of tetrahedron   
return (area_of_tetrahedron);   
}   
float main()   
{   
float side;  
printf("Enter the side of the tetrahedron:");   
scanf("%f",&side);  
printf("Surface area of the tetrahedron is: %f", find_area_of_tetrahedron(side));     
return 0;   
}   

 

Output of Above C program:

Enter the side of the tetrahedron:5
Surface area of the tetrahedron is: 43.301270

 

Program 2: Write a Program in Java language:

// This a  Java program which finds the area of a tetrahedron.  
class findarea {   
static double find_area_of_tetrahedron(float a)   
{    
double area_of_tetrahedron;  
area_of_tetrahedron= ( Math.sqrt(3) * ( a * a )); // It is a formula for calculating the area of tetrahedron   
return(area_of_tetrahedron);   
}   
  
// Driver method   
public static void main(String[] args)   
{   
float side = 3.9;   
System.out.println("The area of a tetrahedron is:");  
System.out.println(find_area_of_tetrahedron(side));   
}   
}  

 

Output of Above Java program:

The area of a tetrahedron is:
43.30127018922193

 

Program 3: Write a Program in PHP programming language.

<?php   
// This a  PHP program which finds the area of a tetrahedron.    
// Function to find area   
function find_area_of_tetrahedron($a)   
{     
$area_of_tetrahedron = ( sqrt(3) * ( $a * $a )); // It is a formula which finds the area and store the value in the area_of_tetrahedron variable.   
return ($area_of_tetrahedron);   
}   
$side = 105;  
echo find_area_of_tetrahedron($side);  

 

Output of Above PHP program:

19095.860153447

 

Program 4: Write a Program in Python programming language.

# This is a python program which finds the area of a tetrahedron.   
from math import sqrt  
def find_area_of_tetrahedron(a):  
    return ( ( sqrt(3) * ( a * a ))) # It is a formula which finds the value of area.  
# main code begins   
side = 5  
print(find_area_of_tetrahedron(side) )  

 

Output of Above Python program:

43.301270

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Miscellaneous Programs Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program to find the Surface Area of the Pe... >>
<< Write a program to find the Volume of Octahedron...