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.

r Decagon inscribed in circle

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.h library for sqrt() 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.

Updated on: 2026-03-15T11:45:55+05:30

268 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements