Before writing the program of calculating the area of a triangular prism in different programming languages, firstly we have to know about the triangular prism and its formula.
What is Triangular Prism?
Triangular Prism is a 3-D shape, which has 5 faces, 6 vertices, and 9 edges.
Area of Triangular Prism
As, the prism contains 2 triangles and 3 rectangles. So,
Surface area of Triangular Prism = (b * h) + (L * (s1 + s2 + s3))
Where, b is the bottom edge of base triangle, L is the prism length, h is the height of base triangle, and s1, s2, and s3 are the three edges of base triangle.
Program of calculating the area of a triangular prism in different Programming languages
Program 1: Write a Program in C language:
Output of Above C program:
Program 2: Write a Program in Java language:
Output of Above Java program:
Program 3: Write a Program in PHP programming language.
Output of Above PHP program:
Program 4: Write a Program in Python programming language.
Output of Above Python program: