Home  >  Article  >  Backend Development  >  Calculation of surface area and volume of hexagonal prism in C programming

Calculation of surface area and volume of hexagonal prism in C programming

王林
王林forward
2023-09-14 09:45:03653browse

Calculation of surface area and volume of hexagonal prism in C programming

The surface area of ​​any figure is the total area covered by its surface.

A hexagonal prism is a three-dimensional figure with hexagons on both ends. The Prism Exam looks like -

In mathematics, a hexagonal prism is defined as a three-dimensional figure with 8 faces, 18 sides, and 12 vertices.

Calculation of surface area and volume of hexagonal prism in C programming

Surface Area = 3ah + 3√3*(a2)
Volume = (3√3/2)a2h

Example

#include <stdio.h>
#include<math.h>
int main() {
   float a = 5, h = 10;
   //Logic to find the area of hexagonal prism
   float Area;
   Area = 6 * a * h + 3 * sqrt(3) * a * a;
   printf("Surface Area: %f</p><p>",Area);
   //Logic to find the Volume of hexagonal prism
   float Volume;
   Volume = 3 * sqrt(3) * a * a * h / 2;
   printf("Volume: %f</p><p>",Volume);
   return 0;
}

Output

Surface Area: 429.903809
Volume: 649.519043

The above is the detailed content of Calculation of surface area and volume of hexagonal prism in C programming. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete