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

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

王林
Release: 2023-09-14 09:45:03
forward
737 people have browsed it

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
Copy after login

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;
}
Copy after login

Output

Surface Area: 429.903809
Volume: 649.519043
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template