Computer >> 컴퓨터 >  >> 프로그램 작성 >> C 프로그래밍

사면체의 면적을 계산하는 프로그램


사면체는 밑변이 삼각형인 피라미드입니다. 즉 밑변이 삼각형이고 각 변에 삼각형이 있습니다. 세 삼각형은 모두 한 점으로 수렴됩니다. 그림과 같이

사면체의 면적 =(√3)a 2

사면체의 면적을 계산하는 프로그램

예시

사면체의 면적을 찾는 코드는 수학 라이브러리를 사용하여 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\n");
   printf("The side of Tetrahedron is %d \n", a);
   area = (sqrt(3)*(a * a));
   printf("The area of Tetrahedron is %f \n", area);
   return 0;
}

출력

Program to find area and volume of Tetrahedron
The side of Tetrahedron is 5
The area of Tetrahedron is 43.301270