首页  >  文章  >  后端开发  >  六角柱的表面积和体积在C编程中的计算

六角柱的表面积和体积在C编程中的计算

王林
王林转载
2023-09-14 09:45:03653浏览

六角柱的表面积和体积在C编程中的计算

任何图形的表面积都是其表面覆盖的总面积。

六角棱柱是两端都有六边形的三维图形。棱柱考试看起来像 -

在数学中,六角棱柱被定义为具有 8 个面、18 个边、12 个顶点的三维图形。

六角柱的表面积和体积在C编程中的计算

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

示例

#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;
}

输出

Surface Area: 429.903809
Volume: 649.519043

以上是六角柱的表面积和体积在C编程中的计算的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除