Q:

Write a program to find the Surface Area of the Pentagonal Prism

belongs to collection: Miscellaneous Programs Examples

0

Before writing the program of calculating the area of a pentagonal prism in different programming languages, firstly we have to know about the pentagonal prism and its area's formula.

What is Pentagonal Prism?

Pentagonal Prism is a 3-D shape, which has 7 faces, 10 vertices, and 15 edges. A pentagonal prism can have pentagonal bases which give five sides. A pentagonal prism is also known as five-sided polygon prism.

Area of Pentagonal Prism

 

Surface area of Pentagonal Prism = 5 * a * b + 5 * b * h  

Where, b is the base length, a is length and h is the height of the pentagonal prism.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program of calculating the area of a pentagonal prism in different Programming languages

Program 1: Write a Program in C language:

// This program which uses a function to find the area of a pentagonal prism .  
#include <stdio.h>  
float find_area_of_Pentagonal_prism(float a, float h, float b) // It is a function to find area   
{   
float area_of_Pentagonal_prism ;  
area_of_Pentagonal_prism =  (5 * a * b) + (5 * b * h); // It is a formula for calculating the area of pentagonal prism    
return (area_of_Pentagonal_prism );   
}   
float main()   
{   
float a = 4.55, h = 9.10, b = 1.5 ;  
printf("Surface area of the pentagonal prism  is: %f", find_area_of_Pentagonal_prism(a, h, b));     
return 0;   
}  

 

Output of Above C program:

Surface area of the pentagonal prism  is: 102.375000

 

Program 2: Write a Program in Java language:

// This is a Java program which finds the area of a pentagonal prism .  
class findarea {   
static float find_area_of_Pentagonal_prism( float a, float h, float b)   
{    
float area_of_Pentagonal_prism ;  
area_of_Pentagonal_prism = (5 * a * b) + (5 * b * h); // It is a formula for calculating the area of pentagonal prism    
return(area_of_Pentagonal_prism);   
}   
// Driver method   
public static void main(String[] args)   
{   
float a = 20;  
float h = 10, b = 2;  
System.out.println("The surface area of a pentagonal prism  is:");  
System.out.println(find_area_of_Pentagonal_prism(a, h, b));   
}   
}  

 

Output of Above Java program:

The surface area of a pentagonal prism  is:
300.0

 

Program 3: Write a Program in PHP programming language.

<?php   
// This is a PHP program which finds the area of a pentagonal prism.    
// Function to find area   
function find_area_of_Pentagonal_prism($a, $h, $b)   
{     
$area_of_Pentagonal_prism = (5 * $a * $b) + (5 * $b * $h); // It is an statement which uses a forumla to find the surface area and store the value in the area_of_pentagonal prism variable.   
return ($area_of_Pentagonal_prism);   
}   
$a = 4;   
$b = 6;   
$h = 8;    
echo find_area_of_Pentagonal_prism($a, $h, $b);   
?>  

 

Output of Above PHP program:

360

 

Program 4: Write a Program in Python programming language.

# This is a python program which finds the area of a pentagonal prism .   
def find_area_of_Pentagonal_prism(a, h, b):  
    return ( (5 * a * b) + (5 * b * h) ) # It is a formula which finds the value of area.  
# main code begins   
a = 9   
h = 2   
b = 15  
print(find_area_of_Pentagonal_prism(a, h, b) )  

 

Output of Above Python program:

825

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Miscellaneous Programs Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program to find the Area of the Rectangula... >>
<< Write a program to find the Area of Tetrahedron...