Given two integers **A** and **B**, denoting the length of a parallelogram and an integer **D**, denoting the length of a diagonal, the task is to find the length of another diagonal of the parallelogram.

**Examples:**

Input:A = 10, B = 30, D = 20Output:40.0

Input:A = 6, B = 8, D = 10Output:10.0

**Approach:**

The relation between sides and diagonals of a parallelogram length of diagonal is given by the equation:

Below is the implementation of the above approach:

## C++

`// C++ Program to implement ` `// the above approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to calculate the length ` `// of the diagonal of a parallelogram ` `// using two sides and other diagonal ` `float` `Length_Diagonal(` `int` `a, ` `int` `b, ` `int` `d) ` `{ ` ` ` ` ` `float` `diagonal = ` `sqrt` `(2 * ((a * a) + ` ` ` `(b * b)) - (d * d)); ` ` ` ` ` `return` `diagonal; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `A = 10; ` ` ` `int` `B = 30; ` ` ` `int` `D = 20; ` ` ` ` ` `// Function Call ` ` ` `float` `ans = Length_Diagonal(A, B, D); ` ` ` ` ` `// Print the final answer ` ` ` `printf` `(` `"%0.1f"` `, ans); ` ` ` `return` `0; ` `} ` ` ` `// This code is contributed by Rohit_ranjan` |

*chevron_right*

*filter_none*

## Java

`// Java Program to implement ` `// the above approach ` `class` `GFG{ ` ` ` `// Function to calculate the length ` `// of the diagonal of a parallelogram ` `// using two sides and other diagonal ` `static` `float` `Length_Diagonal(` `int` `a, ` `int` `b, ` `int` `d) ` `{ ` ` ` ` ` `float` `diagonal = (` `float` `) Math.sqrt(` `2` `* ((a * a) + ` ` ` `(b * b)) - (d * d)); ` ` ` ` ` `return` `diagonal; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `A = ` `10` `; ` ` ` `int` `B = ` `30` `; ` ` ` `int` `D = ` `20` `; ` ` ` ` ` `// Function Call ` ` ` `float` `ans = Length_Diagonal(A, B, D); ` ` ` ` ` `// Print the final answer ` ` ` `System.out.printf(` `"%.1f"` `, ans); ` `} ` `} ` ` ` `// This code is contributed by Rajput-Ji` |

*chevron_right*

*filter_none*

## Python

`# Python Program to implement ` `# the above approach ` ` ` `import` `math ` ` ` `# Function to calculate the length ` `# of the diagonal of a parallelogram ` `# using two sides and other diagonal ` `def` `Length_Diagonal(a, b, d): ` ` ` ` ` `diagonal ` `=` `math.sqrt(` `2` `*` `((a` `*` `*` `2` `) \ ` ` ` `+` `(b` `*` `*` `2` `)) ` `-` `(d` `*` `*` `2` `)) ` ` ` ` ` `return` `diagonal ` ` ` ` ` `# Driver Code ` `A ` `=` `10` `B ` `=` `30` `D ` `=` `20` ` ` `# Function Call ` `ans ` `=` `Length_Diagonal(A, B, D) ` ` ` `# Print the final answer ` `print` `(` `round` `(ans, ` `2` `)) ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to implement ` `// the above approach ` `using` `System; ` `class` `GFG{ ` ` ` `// Function to calculate the length ` `// of the diagonal of a parallelogram ` `// using two sides and other diagonal ` `static` `float` `Length_Diagonal(` `int` `a, ` `int` `b, ` `int` `d) ` `{ ` ` ` ` ` `float` `diagonal = (` `float` `) Math.Sqrt(2 * ((a * a) + ` ` ` `(b * b)) - (d * d)); ` ` ` ` ` `return` `diagonal; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main(String[] args) ` `{ ` ` ` `int` `A = 10; ` ` ` `int` `B = 30; ` ` ` `int` `D = 20; ` ` ` ` ` `// Function Call ` ` ` `float` `ans = Length_Diagonal(A, B, D); ` ` ` ` ` `// Print the readonly answer ` ` ` `Console.Write(` `"{0:F1}"` `, ans); ` `} ` `} ` ` ` `// This code is contributed by Rajput-Ji ` |

*chevron_right*

*filter_none*

**Output:**

40.0

**Time Complexity:** O(1)**Auxiliary Space:** O(1)

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Length of diagonal of a parallelogram using adjacent sides and angle between them
- Find area of parallelogram if vectors of two adjacent sides are given
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Number of ways to arrange 2*N persons on the two sides of a table with X and Y persons on opposite sides
- Count right angled triangles in a matrix having two of its sides parallel to sides of the matrix
- Find other two sides and angles of a right angle triangle
- Length of Diagonals of a Cyclic Quadrilateral using the length of Sides.
- Find other two sides of a right angle triangle
- Find the length of the median of a Triangle if length of sides are given
- Perimeter and Area of Varignon's Parallelogram
- Area of Triangle using Side-Angle-Side (length of two sides and the included angle)
- Find the Missing Point of Parallelogram
- Check whether four points make a parallelogram
- Find all possible coordinates of parallelogram
- Program for Circumference of a Parallelogram
- Program to print the hollow numerical parallelogram
- Program to find the Area of a Parallelogram
- Area of a triangle inside a parallelogram
- Program to calculate area of a parallelogram
- Circumradius of a Cyclic Quadrilateral using the length of Sides

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.