Surface Area and Volume of Hexagonal Prism Last Updated : 07 Aug, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a Base edge and Height of the Hexagonal prism, the task is to find the Surface Area and the Volume of hexagonal Prism. In mathematics, a hexagonal prism is a three-dimensional solid shape which have 8 faces, 18 edges, and 12 vertices. The two faces at either ends are hexagons, and the rest of the faces of the hexagonal prism are rectangular. where a is the base length and h is the height of the hexagonal prism. Surface Area = 6ah + 3\sqrt{3}a^{2} Volume = \frac{3\sqrt{3}}{2}a^{2}h Examples: Input : a = 4, h = 3 Output : Surface Area: 155.138443 Volume: 124.707657 Input : a = 5, h = 10 Output : Surface Area: 429.904 Volume: 649.519 C++ // C++ program to find the Surface Area // and Volume of Hexagonal Prism. #include <bits/stdc++.h> using namespace std; // Function to calculate Surface area void findSurfaceArea(float a, float h) { float Area; // Formula to calculate surface area Area = 6 * a * h + 3 * sqrt(3) * a * a; // Display surface area cout << "Surface Area: " << Area; cout << "\n"; } // Function to calculate Volume void findVolume(float a, float h) { float Volume; // formula to calculate Volume Volume = 3 * sqrt(3) * a * a * h / 2; // Display Volume cout << "Volume: " << Volume; } // Driver Code int main() { float a = 5, h = 10; // surface area function call findSurfaceArea(a, h); // volume function call findVolume(a, h); return 0; } Java // Java program to find the Surface Area // and Volume of Hexagonal Prism. import java.io.*; class GFG { // Function to calculate Surface area static void findSurfaceArea(float a, float h) { float Area; // Formula to calculate surface area Area = 6 * a * h + 3 * (float)(Math.sqrt(3)) * a * a; // Display surface area System.out.println("Surface Area: " + Area); } // Function to calculate Volume static void findVolume(float a, float h) { float Volume; // formula to calculate Volume Volume = 3 * (float)(Math.sqrt(3)) * a * a * h / 2; // Display Volume System.out.println("Volume: " + Volume); } // Driver code public static void main (String[] args) { float a = 5, h = 10; // surface area function call findSurfaceArea(a, h); // volume function call findVolume(a, h); } } Python3 # Python3 program to find the # Surface Area and Volume # of Hexagonal Prism. import math # Function to calculate # Surface area def findSurfaceArea(a, h): Area = 0; # Formula to calculate # surface area Area = (6 * a * h + 3 * math.sqrt(3) * a * a); # Display surface area print("Surface Area:", round(Area, 3)); # Function to # calculate Volume def findVolume(a, h): Volume = 0; # formula to # calculate Volume Volume = (3 * math.sqrt(3) * a * a * h / 2); # Display Volume print("Volume:", round(Volume, 3)); # Driver Code a = 5; h = 10; # surface area # function call findSurfaceArea(a, h); # volume function call findVolume(a, h); # This code is contributed # by mits C# // C# program to find the // Surface Area and Volume // of Hexagonal Prism. using System; class GFG { // Function to calculate // Surface area static void findSurfaceArea(float a, float h) { float Area; // Formula to calculate // surface area Area = 6 * a * h + 3 * (float)(Math.Sqrt(3)) * a * a; // Display surface area Console.WriteLine("Surface Area: " + Area); } // Function to // calculate Volume static void findVolume(float a, float h) { float Volume; // formula to calculate Volume Volume = 3 * (float)(Math.Sqrt(3)) * a * a * h / 2; // Display Volume Console.WriteLine("Volume: " + Volume); } // Driver code public static void Main () { float a = 5, h = 10; // surface area // function call findSurfaceArea(a, h); // volume function call findVolume(a, h); } } // This code is contributed // by anuj_67. PHP <?php // PHP program to find the // Surface Area and Volume // of Hexagonal Prism. // Function to calculate // Surface area function findSurfaceArea($a, $h) { $Area; // Formula to calculate // surface area $Area = 6 * $a * $h + 3 * sqrt(3) * $a * $a; // Display surface area echo "Surface Area: " , $Area,"\n"; } // Function to // calculate Volume function findVolume($a, $h) { $Volume; // formula to // calculate Volume $Volume = 3 * sqrt(3) * $a * $a * $h / 2; // Display Volume echo "Volume: " , $Volume; } // Driver Code $a = 5; $h = 10; // surface area // function call findSurfaceArea($a, $h); // volume function call findVolume($a, $h); // This code is contributed // by anuj_67. ?> JavaScript <script> // javascript program to find the Surface Area // and Volume of Hexagonal Prism. // Function to calculate Surface area function findSurfaceArea( a, h) { let Area; // Formula to calculate surface area Area = 6 * a * h + 3 * Math.sqrt(3) * a * a; // Display surface area document.write( "Surface Area: " + Area.toFixed(3) + "<br/>"); } // Function to calculate Volume function findVolume( a, h) { let Volume; // formula to calculate Volume Volume = 3 * Math.sqrt(3) * a * a * h / 2; // Display Volume document.write( "Volume: " + Volume.toFixed(3)); } // Driver Code let a = 5, h = 10; // surface area function call findSurfaceArea(a, h); // volume function call findVolume(a, h); // This code is contributed by todaysgaurav </script> Time complexity : O(1) as performing constant operationsAuxiliary Space : O(1) Comment More infoAdvertise with us Next Article Graph measurements: length, distance, diameter, eccentricity, radius, center K Kanishk_Verma Follow Improve Article Tags : DSA Similar Reads Graph measurements: length, distance, diameter, eccentricity, radius, center A graph is defined as a set of points known as 'Vertices' and a line joining these points is known as 'Edges'. It is a set consisting of where 'V' is vertices and 'E' is edge. Vertices: {A, B, C, D, E, F} Edges: {{A, B}, {A, D}, {A, E}, {B, C}, {C, E}, {C, F}, {D, E}, {E, F}} Graph Measurements: The 5 min read Relationship between number of nodes and height of binary tree Binary Tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. It is commonly used in computer science for efficient storage and retrieval of data, with various operations such as insertion, deletion, and traversal.Prerequ 2 min read Matrices Matrices are key concepts in mathematics, widely used in solving equations and problems in fields like physics and computer science. A matrix is simply a grid of numbers, and a determinant is a value calculated from a square matrix.Example: \begin{bmatrix} 6 & 9 \\ 5 & -4 \\ \end{bmatrix}_{2 3 min read Different Operations on Matrices For an introduction to matrices, you can refer to the following article: Matrix Introduction In this article, we will discuss the following operations on matrices and their properties: Matrices AdditionMatrices SubtractionMatrices MultiplicationMatrices Addition: The addition of two matrices A m*n a 11 min read Eigenvalues and Eigenvectors Eigenvalues and eigenvectors are fundamental concepts in linear algebra, used in various applications such as matrix diagonalization, stability analysis and data analysis (e.g., PCA). They are associated with a square matrix and provide insights into its properties.Eigen value and Eigen vectorTable 10 min read System of Linear Equations A system of linear equations is a set of two or more linear equations involving the same variables. Each equation represents a straight line or a plane and the solution to the system is the set of values for the variables that satisfy all equations simultaneously.Here is simple example of system of 5 min read LU Decomposition LU decomposition or factorization of a matrix is the factorization of a given square matrix into two triangular matrices, one upper triangular matrix and one lower triangular matrix, such that the product of these two matrices gives the original matrix. It is a fundamental technique in linear algebr 6 min read Doolittle Algorithm | LU Decomposition Doolittle Algorithm: The Doolittle Algorithm is a method for performing LU Decomposition, where a given matrix is decomposed into a lower triangular matrix L and an upper triangular matrix U. This decomposition is widely used in solving systems of linear equations, inverting matrices, and computing 11 min read Limits, Continuity and Differentiability Limits, Continuity, and Differentiation are fundamental concepts in calculus. They are essential for analyzing and understanding function behavior and are crucial for solving real-world problems in physics, engineering, and economics.Table of ContentLimitsKey Characteristics of LimitsExample of Limi 10 min read Cauchy's Mean Value Theorem Cauchy's Mean Value theorem provides a relation between the change of two functions over a fixed interval with their derivative. It is a special case of Lagrange Mean Value Theorem. Cauchy's Mean Value theorem is also called the Extended Mean Value Theorem or the Second Mean Value Theorem.According 7 min read Like