Before writing the program of calculating the area of a hexagonal prism in different programming languages, firstly we have to know about the hexagonal prism and its formulae of surface area.
What is Hexagonal Prism?
Hexagonal Prism is a 3-D shape, which has 8 faces, 12 vertices, and 18 edges. The two faces at either ends of the prism are hexagons, and the rest of the faces of the hexagonal prism are rectangular.
Area of Hexagonal Prism
Surface area of Hexagonal Prism = (6 * a * h) + (3 * √3 * a * a)
Where, a and h is the base length and height of the hexagonal prism.
Program of calculating the area of a hexagonal prism in different Programming languages
Program 1: Write a Program in C language:
Output of Above C program:
Program 2: Write a Program in Java language:
Output of Above Java program:
Program 3: Write a Program in PHP programming language.
Output of Above PHP program:
Program 4: Write a Program in Python programming language.
Output of Above Python program: