八邊形面積計算程式


八邊形是一種八邊多邊形。要計算八邊形面積,使用以下公式:

八邊形面積 = ((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

更新於: 30-Jul-2019

636 次瀏覽

開啟您的 職業生涯

透過完成課程獲證

開始
廣告