팔각형은 8면이 있는 다각형입니다. 팔각형의 면적을 계산하기 위해 다음 공식이 사용됩니다.
팔각형 면적 =((a 2 *2) / *tan (22.5°)) =((2*a*a)(1+√2))
코드 논리, 8변이 있는 다각형의 면적은 위의 공식을 사용하여 계산됩니다. 표현식은 sqrt 함수를 사용하여 2의 제곱근을 찾습니다. 표현식의 값은 부동 소수점 값으로 평가되어 부동 소수점 영역 변수에 넣어집니다.
예시
#include <stdio.h>
#include <math.h>
int main(){
int a = 7;
float area;
float multiplier = 6.18;
printf("Program to find area of octagon \n");
printf("The side of the octagon is %d \n", a);
area = ((2*a*a)*(1 + sqrt(2)));
printf("The area of Enneagon is %f \n", area);
return 0;
} 출력
Program to find area of octagon The side of the octagon is 7 The area of Enneagon is 236.592926