Area of circle inscribed within rhombus in C Program?

In C, we can calculate the area of a circle inscribed within a rhombus using the diagonals of the rhombus. When a circle is inscribed in a rhombus with diagonals 'a' and 'b', the circle touches all four sides of the rhombus.

a b r

Syntax

float circleArea = (M_PI * (a * b * a * b)) / (4 * (a * a + b * b));

Where 'a' and 'b' are the diagonals of the rhombus. The formula is derived from the fact that the radius of the inscribed circle equals (a * b) / (2 * sqrt(a² + b²)).

Mathematical Derivation

The diagonals of a rhombus create four equal right-angled triangles. Each side of the rhombus is the hypotenuse of these triangles −

  • Side length = ?((a/2)² + (b/2)²) = ?(a² + b²)/2
  • Radius of inscribed circle = Area of rhombus / (2 × Perimeter)
  • Area of circle = ? × r²

Example

This program calculates the area of a circle inscribed in a rhombus with given diagonals −

#include <stdio.h>
#include <math.h>

float calculateCircleArea(float a, float b) {
    if (a <= 0 || b <= 0) {
        printf("Error: Diagonal lengths must be positive<br>");
        return -1;
    }
    
    float area = (M_PI * (a * b * a * b)) / (4 * (a * a + b * b));
    return area;
}

int main() {
    float a = 8, b = 10;
    float area;
    
    printf("Rhombus diagonals: a = %.1f, b = %.1f<br>", a, b);
    area = calculateCircleArea(a, b);
    
    if (area != -1) {
        printf("Area of inscribed circle: %.4f square units<br>", area);
    }
    
    return 0;
}
Rhombus diagonals: a = 8.0, b = 10.0
Area of inscribed circle: 30.6488 square units

Key Points

  • The formula uses the relationship between the rhombus diagonals and the inscribed circle radius.
  • Input validation ensures positive diagonal values to avoid mathematical errors.
  • The constant M_PI from math.h provides better precision than hardcoded values.

Conclusion

Calculating the area of a circle inscribed in a rhombus requires the diagonal lengths and the derived formula ?(ab)²/(4(a²+b²)). This method provides accurate results for any valid rhombus dimensions.

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

235 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements