首頁  >  文章  >  後端開發  >  六角柱的表面積和體積在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刪除