Un prisma que tiene 5 caras rectangulares y 2 bases pentagonales paralelas es un prisma pentagonal. Entonces te dan la longitud de la apotema (a) , la longitud de la base (b) y la altura (h) del prisma pentagonal. tienes que encontrar el área de la superficie y el volumen del prisma pentagonal.
Ejemplos:
Input : a=3, b=5, h=6 Output :surface area=225, volume=225 Input : a=2, b=3, h=5 Output :surface area=105, volume=75
En esta figura,
a – apotema longitud del Prisma Pentagonal.
b – longitud de la base del Prisma Pentagonal.
h – altura del Prisma Pentagonal.
Fórmulas: A continuación se encuentran las fórmulas para calcular el área de superficie y el volumen del Prisma Pentagonal.
C++
// CPP program to find // surface area and volume of the // Pentagonal Prism #include <bits/stdc++.h> using namespace std; // function for surface area float surfaceArea(float a, float b, float h) { return 5 * a * b + 5 * b * h; } // function for VOlume float volume(float b, float h) { return (5 * b * h) / 2; } // Driver function int main() { float a = 5; float b = 3; float h = 7; cout << "surface area= " << surfaceArea(a, b, h) << ", "; cout << "volume= " << volume(b, h); }
Java
// Java program to find // surface area and volume of the // Pentagonal Prism import java.util.*; class solution { // function for surface area static float surfaceArea(float a, float b, float h) { return 5 * a * b + 5 * b * h; } // function for VOlume static float volume(float b, float h) { return (5 * b * h) / 2; } // Driver function public static void main(String arr[]) { float a = 5; float b = 3; float h = 7; System.out.println( "surface area= "+surfaceArea(a, b, h)+", "); System.out.println("volume= "+volume(b, h)); } }
Python3
# Python 3 program to find surface area # and volume of the Pentagonal Prism # function for surface area def surfaceArea(a, b, h): return 5 * a * b + 5 * b * h # function for VOlume def volume(b, h): return (5 * b * h) / 2 # Driver Code if __name__ == '__main__': a = 5 b = 3 h = 7 print("surface area =", surfaceArea(a, b, h), ",", "volume =", volume(b, h)) # This code is contributed by # Sanjit_Prasad
C#
// C# program to find surface // area and volume of the // Pentagonal Prism using System; class GFG { // function for surface area static float surfaceArea(float a, float b, float h) { return 5 * a * b + 5 * b * h; } // function for VOlume static float volume(float b, float h) { return (5 * b * h) / 2; } // Driver Code public static void Main() { float a = 5; float b = 3; float h = 7; Console.WriteLine("surface area = " + surfaceArea(a, b, h) + ", "); Console.WriteLine("volume = " + volume(b, h)); } } // This code is contributed by vt_m
PHP
<?php // PHP program to find // surface area and volume // of the Pentagonal Prism // function for surface area function surfaceArea($a, $b, $h) { return 5 * $a * $b + 5 * $b * $h; } // function for VOlume function volume($b, $h) { return (5 * $b * $h) / 2; } // Driver Code $a = 5; $b = 3; $h = 7; echo "surface area = " , surfaceArea($a, $b, $h) , ", "; echo "volume = " , volume($b, $h); // This code is contributed by vt_m ?>
Javascript
<script> // javascript program to find // surface area and volume of the // Pentagonal Prism // function for surface area function surfaceArea( a, b, h) { return 5 * a * b + 5 * b * h; } // function for VOlume function volume( b, h) { return (5 * b * h) / 2; } // Driver function let a = 5; let b = 3; let h = 7; document.write( "surface area= " + surfaceArea(a, b, h) + ", "); document.write( "volume= " + volume(b, h)); // This code is contributed by todaysgaurav </script>
surface area= 180, volume= 52.5
Complejidad del tiempo: O(1)
Espacio Auxiliar: O(1)
Publicación traducida automáticamente
Artículo escrito por SURENDRA_GANGWAR y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA