# Program to calculate the Surface Area of a Triangular Prism

In mathematics, a triangular prism is a three-dimensional solid shape with two identical ends connected by equal parallel lines, and have 5 faces, 9 edges, and 6 vertices.

where “b” is the length of the base, “h” is the height of the triangle, “s1, s2, s3” are the respective length of each side of the triangle, and H is the height of the prism (which is also the length of the rectangle).

Given the base, the height of the triangle, height of prism and the length of each side of triangle base and the task is to calculate the surface area of the triangular prism.

**Examples:**

Input:b = 3, h = 4, s1 = 3, s2 = 6, s3 = 6, Ht = 8

Output:The area of triangular prism is 132.000000

Input:b = 2, h = 3, s1 = 4, s2 = 5, s3 = 6, Ht = 8

Output:The area of triangular prism is 126.000000

**Formula for calculating the surface area: **

As stated above, the prism contains two triangles of the area **(1/2)*(b)*(h)** and three rectangles of the area **H*s1, H*s2 and H*s3**.

Now after adding all the terms we get the total surface area:

SA = b * h + (s1 + s2 + s3 ) * H

## C++

`// C++ Program to calculate the ` `// Surface area of a triangular prism ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function for calculating the area ` `void` `Calculate_area() ` `{ ` ` ` `// Initialization ` ` ` `float` `b = 3, h = 4, s1 = 3, s2 = 6; ` ` ` `float` `s3 = 6, Ht = 8, SA; ` ` ` ` ` `// Formula for calculating the area ` ` ` `SA = b * h + (s1 + s2 + s3) * Ht; ` ` ` ` ` `// Displaying the area ` ` ` `cout << ` `"The area of triangular prism is : "` `<< SA; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `// Function calling ` ` ` `Calculate_area(); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## C

`// C Program to calculate the ` `// Surface area of a triangular prism ` `#include <stdio.h> ` ` ` `// Function for calculating the area ` `void` `Calculate_area() ` `{ ` ` ` `// Initialization ` ` ` `float` `b = 3, h = 4, s1 = 3, s2 = 6; ` ` ` `float` `s3 = 6, Ht = 8, SA; ` ` ` ` ` `// Formula for calculating the area ` ` ` `SA = b * h + (s1 + s2 + s3) * Ht; ` ` ` ` ` `// Displaying the output ` ` ` `printf` `(` `"The area of triangular prism is : %f"` `, SA); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `// Function calling ` ` ` `Calculate_area(); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java Program to calculate the ` `// Surface area of a triangular prism ` ` ` `import` `java.util.Scanner; ` `public` `class` `Prism { ` ` ` ` ` `public` `static` `void` `Calculate_area() ` ` ` `{ ` ` ` `// Initialization ` ` ` `double` `b = ` `3` `, h = ` `4` `, s1 = ` `3` `, s2 = ` `6` `; ` ` ` `double` `s3 = ` `6` `, Ht = ` `8` `, SA; ` ` ` ` ` `// Formula for calculating the area ` ` ` `SA = b * h + (s1 + s2 + s3) * Ht; ` ` ` ` ` `// Displaying the area ` ` ` `System.out.printf(` `"The area of triangular prism is : %f"` `, SA); ` ` ` `} ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `Calculate_area(); ` ` ` `} ` `} ` `// This code is contributed by Nishant Tanwar ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 Program to calculate the ` `# Surface area of a triangular prism ` ` ` `# Function for calculating the area ` `def` `Calculate_area(): ` ` ` ` ` `# Initialization ` ` ` `b ` `=` `3` ` ` `h ` `=` `4` ` ` `s1 ` `=` `3` ` ` `s2 ` `=` `6` ` ` `s3 ` `=` `6` ` ` `Ht ` `=` `8` ` ` ` ` `# Formula for calculating the area ` ` ` `SA ` `=` `b ` `*` `h ` `+` `(s1 ` `+` `s2 ` `+` `s3) ` `*` `Ht ` ` ` ` ` `# Displaying the area ` ` ` `print` `(` `"The area of triangular prism is :"` `,SA) ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` `# Function calling ` ` ` `Calculate_area() ` ` ` `# This code is contributed by ` `# Surendra_Gangwar ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to calculate the ` `// Surface area of a triangular prism ` `using` `System; ` `public` `class` `Prism { ` ` ` ` ` `static` `void` `Calculate_area() ` ` ` `{ ` ` ` `// Initialization ` ` ` `double` `b = 3, h = 4, s1 = 3, s2 = 6; ` ` ` `double` `s3 = 6, Ht = 8, SA; ` ` ` ` ` `// Formula for calculating the area ` ` ` `SA = b * h + (s1 + s2 + s3) * Ht; ` ` ` ` ` `// Displaying the area ` ` ` `Console.WriteLine(` `"The area of triangular prism is : "` `+ SA); ` ` ` `} ` ` ` `static` `public` `void` `Main(String[] args) ` ` ` `{ ` ` ` `Calculate_area(); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to calculate ` `// the Surface area of a ` `// triangular prism ` ` ` `// Function for calculating ` `// the area ` `function` `Calculate_area() ` `{ ` ` ` `// Initialization ` ` ` `$b` `= 3; ` `$h` `= 4; ` ` ` `$s1` `= 3; ` `$s2` `= 6; ` ` ` `$s3` `= 6; ` `$Ht` `= 8; ` `$SA` `; ` ` ` ` ` `// Formula for calculating ` ` ` `// the area ` ` ` `$SA` `= ` `$b` `* ` `$h` `+ (` `$s1` `+ ` ` ` `$s2` `+ ` `$s3` `) * ` `$Ht` `; ` ` ` ` ` `// Displaying the area ` ` ` `echo` `"The area of triangular"` `. ` ` ` `" prism is : "` `, ` `$SA` `; ` `} ` ` ` `// Driver code ` ` ` `// Function calling ` `Calculate_area(); ` ` ` `// This code is contributed by m_kit ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

The area of triangular prism is : 132.000000

## Recommended Posts:

- Program to find volume and surface area of pentagonal prism
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Surface Area and Volume of Hexagonal Prism
- Program to calculate Volume and Surface area of Hemisphere
- Program to find the Volume of a Triangular Prism
- Calculate volume and surface area of Torus
- Calculate volume and surface area of a cone
- Calculate Volume and Surface area Of Sphere
- Program for Surface Area of Octahedron
- Program for Volume and Surface Area of Cuboid
- Program for Volume and Surface Area of Cube
- Program for Volume and Surface area of Frustum of Cone
- Program to find the surface area of the square pyramid
- Program to calculate Area Of Octagon
- Program to calculate the area of Kite

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.