計算四面體的表面積程式
四面體是具有三角形底座的金字塔,即它的底座是一個三角形,且每側都有一個三角形。全部三個三角形匯聚於一點。如下圖所示:
四面體的表面積 = (√3)a2

示例
獲取四面體面積的程式碼使用 math 庫來使用 sqrt 和 pow 方法獲取數字的平方和平方根。為了計算面積,我們採用了一個浮點,並將其賦值為表示式“((sqrt(3)*a*a))”。
#include <stdio.h>
#include <math.h>
int main() {
int a= 5;
float area, volume;
printf("Program to find area and volume of Tetrahedron
");
printf("The side of Tetrahedron is %d
", a);
area = (sqrt(3)*(a * a));
printf("The area of Tetrahedron is %f
", area);
return 0;
}輸出
Program to find area and volume of Tetrahedron The side of Tetrahedron is 5 The area of Tetrahedron is 43.301270
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP