Program to find the perimeter of a rhombus using diagonals

A rhombus is a quadrilateral where all four sides have equal length. The perimeter of a rhombus can be calculated using two methods: adding all sides or using the diagonal lengths. When using diagonals, we apply the mathematical relationship between the diagonals and side length.

Syntax

perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2));

Where d1 and d2 are the lengths of the two diagonals.

Mathematical Formula

The perimeter of a rhombus using diagonals is calculated as:

Perimeter = 2 × ?(d1² + d2²)

d1 d2 side

Example

This program calculates the perimeter of a rhombus using its diagonal lengths −

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

int main() {
    double d1 = 3.0, d2 = 4.0;
    double perimeter;
    
    /* Calculate perimeter using diagonal formula */
    perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2));
    
    printf("Diagonal 1: %.2f<br>", d1);
    printf("Diagonal 2: %.2f<br>", d2);
    printf("Perimeter of rhombus: %.2f<br>", perimeter);
    
    return 0;
}
Diagonal 1: 3.00
Diagonal 2: 4.00
Perimeter of rhombus: 10.00

How It Works

  • In a rhombus, diagonals bisect each other at right angles
  • Each diagonal divides the rhombus into two congruent right triangles
  • Using Pythagorean theorem: side = ?((d1/2)² + (d2/2)²)
  • Simplifying: side = ?(d1² + d2²)/2
  • Perimeter = 4 × side = 2?(d1² + d2²)

Note: Ensure you link the math library during compilation using -lm flag if required on your system.

Conclusion

The perimeter of a rhombus can be efficiently calculated using its diagonals with the formula 2?(d1² + d2²). This method is particularly useful when diagonal lengths are known instead of side lengths.

Updated on: 2026-03-15T10:45:53+05:30

374 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements