Here we will learn how to get the area of a decagon inside a circle. The radius is given. The side of the decagon is "a".
As we all know, the side lengths of a decagon are as follows-
#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
The above is the detailed content of C program to find the area of a decagon inscribed in a circle?. For more information, please follow other related articles on the PHP Chinese website!