Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
C Program for area of decagon inscribed within the circle?
Here we will see how to get the area of a decagon inscribed within a circle. A decagon is a 10-sided polygon, and when inscribed in a circle, all vertices of the decagon lie on the circumference of the circle. Given the radius of the circle, we can calculate the area of the inscribed decagon.
Syntax
float area = (5 * r * r * (sqrt(5) - 1) * sqrt(10 + 2 * sqrt(5))) / 4;
Mathematical Formula
For a regular decagon inscribed in a circle of radius r, the area is calculated using −
Area = (5/4) × r² × (?5 - 1) × ?(10 + 2?5)
This formula is derived from the fact that a decagon can be divided into 10 congruent triangles, each with its vertex at the center of the circle.
Example
Let's calculate the area of a decagon inscribed in a circle with radius 8 units −
#include <stdio.h>
#include <math.h>
float decagonArea(float r) {
if (r < 0) {
return -1; // Invalid radius
}
float area = (5.0 * r * r * (sqrt(5) - 1) * sqrt(10 + 2 * sqrt(5))) / 4.0;
return area;
}
int main() {
float radius = 8.0;
float result = decagonArea(radius);
if (result == -1) {
printf("Invalid radius!<br>");
} else {
printf("Radius of circle: %.1f units<br>", radius);
printf("Area of inscribed decagon: %.3f square units<br>", result);
}
return 0;
}
Radius of circle: 8.0 units Area of inscribed decagon: 190.211 square units
Key Points
- A decagon inscribed in a circle has all 10 vertices touching the circle's circumference.
- The formula involves square roots and requires the
math.hlibrary forsqrt()function. - Always validate input to ensure the radius is positive.
Conclusion
The area of a decagon inscribed in a circle can be calculated using the mathematical formula involving the circle's radius. This formula utilizes trigonometric relationships and provides an exact solution for regular decagons.
