Dada la longitud, el ancho y la altura de un prisma triangular, la tarea es encontrar el volumen del prisma triangular.
Ejemplos:
Input: l = 18, b = 12, h = 9 Output: Volume of triangular prism: 972 Input: l = 10, b = 8, h = 6 Output: Volume of triangular prism: 240
En matemáticas, un prisma triangular es una forma sólida tridimensional con dos extremos idénticos conectados por líneas paralelas iguales. El prisma triangular contiene 5 caras, 9 aristas y 6 vértices.
Fórmula para hallar el volumen de un prisma triangular:
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; }
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)); } }
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))
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)); } }
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); ?>
Javascript
<script> // Javascript 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 let volume = (l * b * h) / 2; return volume; } // Driver Code let l = 18, b = 12, h = 9; // function calling document.write( "Volume of triangular prism: " + findVolume(l, b, h)); // This code is contributed by todaysgaurav </script>
Producción:
Volume of triangular prism: 972
Complejidad de Tiempo : O(1)
Espacio Auxiliar : O(1)
Publicación traducida automáticamente
Artículo escrito por Kanishk_Verma y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA