圓內十邊形面積的 C 語言程式?


這裡,我們將瞭解如何計算圓內十邊形的面積。半徑已給出。十邊形的邊長為“a”。

我們知道十邊形的邊長如下 −

因此面積為 −

示例

#include <iostream>
#include <cmath>
using namespace std;
float area(float r) {
   if (r < 0) //if r is negative it is invalid
      return -1;
   float area = (5 * pow(r, 2) * (3 - sqrt(5)) * (sqrt(5) + (2 * sqrt(5)))) / 4;
   return area;
}
int main() {
   float r = 8;
   cout << "Area : " << area(r);
}

輸出

Area : 409.969

更新時間: 20-Aug-2019

146 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始
廣告