Given the length, width, and height of a triangular prism, the task is to find the volume of the triangular prism.

Examples:

Input:l = 18, b = 12, h = 9Output:Volume of triangular prism: 972Input:l = 10, b = 8, h = 6Output:Volume of triangular prism: 240

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

Formula to find the volume of triangular prism:

Volume = ( l * b * h ) / 2

## C++

`// CPP program to find the volume ` `// of the triangular prism ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// function to find the Volume ` `// of triangular prism ` `float` `findVolume(` `float` `l, ` `float` `b, ` `float` `h) ` `{ ` ` ` `// formula to find Volume ` ` ` `float` `volume = (l * b * h) / 2; ` ` ` ` ` `return` `volume; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `float` `l = 18, b = 12, h = 9; ` ` ` ` ` `// function calling ` ` ` `cout << ` `"Volume of triangular prism: "` ` ` `<< findVolume(l, b, h); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find the volume ` `// of the triangular prism ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` ` ` `// function to find the Volume ` ` ` `// of triangular prism ` ` ` `static` `float` `findVolume(` `float` `l, ` `float` `b, ` `float` `h) ` ` ` `{ ` ` ` `// formula to find Volume ` ` ` `float` `volume = (l * b * h) / ` `2` `; ` ` ` ` ` `return` `volume; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `float` `l = ` `18` `, b = ` `12` `, h = ` `9` `; ` ` ` ` ` `// function calling ` ` ` `System.out.println(` `"Volume of triangular prism: "` ` ` `+ findVolume(l, b, h)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find the volume ` `# of the triangular prism ` ` ` `# function to find the Volume ` `# of triangular prism ` `def` `findVolume(l, b, h) : ` ` ` ` ` `# formula to find Volume ` ` ` `return` `((l ` `*` `b ` `*` `h) ` `/` `2` `) ` ` ` `# Driver Code ` `l ` `=` `18` `b ` `=` `12` `h ` `=` `9` ` ` `# function calling ` `print` `(` `"Volume of triangular prism: "` `, ` ` ` `findVolume(l, b, h)) ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find the volume ` `// of the triangular prism ` `using` `System; ` ` ` `class` `GFG { ` ` ` ` ` `// function to find the Volume ` ` ` `// of triangular prism ` ` ` `static` `float` `findVolume(` `float` `l, ` `float` `b, ` `float` `h) ` ` ` `{ ` ` ` `// formula to find Volume ` ` ` `float` `volume = (l * b * h) / 2; ` ` ` ` ` `return` `volume; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `static` `public` `void` `Main() ` ` ` `{ ` ` ` `float` `l = 18, b = 12, h = 9; ` ` ` ` ` `// function calling ` ` ` `Console.WriteLine(` `"Volume of triangular prism: "` ` ` `+ findVolume(l, b, h)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find the volume ` `// of the triangular prism ` ` ` `// function to find the Volume ` `// of triangular prism ` `function` `findVolume(` `$l` `, ` `$b` `, ` `$h` `) ` `{ ` ` ` `// formula to find Volume ` ` ` `$volume` `= (` `$l` `* ` `$b` `* ` `$h` `) / 2; ` ` ` ` ` `return` `$volume` `; ` `} ` ` ` `// Driver Code ` `$l` `= 18; ` `$b` `= 12; ` `$h` `= 9; ` ` ` `// function calling ` `echo` `"Volume of triangular prism: "` ` ` `. findVolume(` `$l` `, ` `$b` `, ` `$h` `); ` ` ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

Volume of triangular prism: 972

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Program to find volume and surface area of pentagonal prism
- Program to find Surface Area and Volume of Octagonal Prism
- Program to calculate the Surface Area of a Triangular Prism
- Surface Area and Volume of Hexagonal Prism
- Minimum number of blocks required to form Hollow Rectangular Prism
- Program to find the Area and Volume of Icosahedron
- Program to find the Volume of an irregular tetrahedron
- Program to print triangular number series till n
- Program to check if N is a Centered Triangular Number
- Find the sequence number of a triangular number
- Program for Volume and Surface Area of Cube
- Program for Volume and Surface Area of Cuboid
- Program for volume of Pyramid
- Program to calculate volume of Ellipsoid
- Program to calculate area and volume of a Tetrahedron
- Program to calculate Volume and Surface area of Hemisphere
- Program for Volume and Surface area of Frustum of Cone
- Program to calculate volume of Octahedron
- Find the volume of rectangular right wedge
- Find the concentration of a solution using given Mass and Volume

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.