八邊形面積計算程式
八邊形是一種八邊多邊形。要計算八邊形面積,使用以下公式:
八邊形面積 = ((a2*2) / *tan (22.5°)) = ((2*a*a)(1+√2))
程式碼邏輯,使用上面的公式計算八邊多邊形面積。表示式使用 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
");
printf("The side of the octagon is %d
", a);
area = ((2*a*a)*(1 + sqrt(2)));
printf("The area of Enneagon is %f
", area);
return 0;
}輸出
Program to find area of octagon The side of the octagon is 7 The area of Enneagon is 236.592926
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP