Given integers A and B denoting the length of sides of a parallelogram and Ythat is the angle between the sides and length of diagonals D1 and D2 of the parallelogram and an angle 0 at the intersection of the diagonal, the task is to find the area of the parallelogram from the information provided.

A parallelogram is a type of quadrilateral that has equal and parallel opposite sides and angle between them is not right angle.

Examples:

Input: A = 6, B = 10, 0 = 30 Output: 18.48 Explanation: For the given sides 6 and 10 and for the angle 30 degree the area of parallelogram will be 18.48.

Input: A = 3, B = 5, Y = 45 Output: 10.61 Explanation: For the given sides 3 and 5 and for the angle 45 degree the length of diagonal will be 10.61.

Input: D1 = 3, D2 = 5, 0 = 90 Output: 7.5 Explanation: For the given diagonals 3 and 5 and for the angle 90 degree the area of parallelogram will be 7.5.

Approach: The area of the parallelogram can be calculated by the following three formulas:

From given sides A and B and the angle between the diagonals, the area of the parallelogram can be calculated by the following formula:

Area of Parallelogram for sides and angle between diagonals = ((A2 – B2) * tan 0) / 2

From given sides A and B and the angle between the sides, the area of the parallelogram is can be calculated by the following formula:

Area of Parallelogram for sides and angle between sides = A * B * sin Y

From the given length of diagonals D1 and D2 and the angle between them, the area of the parallelogram can be calculated by the following formula:

Area of Parallelogram for diagonals and angle between diagonals = (D1 * D2 * sin 0)/2

Below is the implementation of the above approach:

C++

// C++ program for the

// above approach

#include <bits/stdc++.h>

usingnamespacestd;

{

doublepi = 3.14159265359;

return((double)degree * (pi / 180));

}

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of diagonal

doubleArea_Parallelogram1(inta, intb,

inttheta)

{

// Calculate area of parallelogram

doublearea = (abs(tan(toRadians(theta))) / 2) *

abs(a * a – b * b);

returnarea;

}

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of sides

doubleArea_Parallelogram2(inta, intb,

intgamma)

{

// Calculate area of parallelogram

abs(a * b);

returnarea;

}

// Function to return the area of

// parallelogram using diagonals and

// angle at the intersection of diagonals

staticdoubleArea_Parallelogram3(intd1, intd2,

inttheta)

{

// Calculate area of parallelogram

doublearea = (abs(sin(toRadians(theta))) / 2) *

abs(d1 * d2);

returnarea;

}

// Driver Code

intmain()

{

// Given diagonal and angle

intd1 = 3;

intd2 = 5;

inttheta = 90;

// Function call

doublearea = Area_Parallelogram3(d1,

d2,

theta);

// Print the area

printf(“%.2f”, area);

}

// This code is contributed by rutvik_56

Java

// Java program for above approach

importjava.io.*;

classGFG{

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of diagonal

staticdoubleArea_Parallelogram1(inta, intb,

inttheta)

{

// Calculate area of parallelogram

doublearea = (Math.abs(Math.tan(

Math.abs(a * a – b * b);

returnarea;

}

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of sides

staticdoubleArea_Parallelogram2(inta, intb,

intgamma)

{

// Calculate area of parallelogram

doublearea = (Math.abs(Math.sin(

Math.abs(a * b);

returnarea;

}

// Function to return the area of

// parallelogram using diagonals and

// angle at the intersection of diagonals

staticdoubleArea_Parallelogram3(intd1, intd2,

inttheta)

{

// Calculate area of parallelogram

doublearea = (Math.abs(Math.sin(

Math.abs(d1 * d2);

returnarea;

}

// Driver code

publicstaticvoidmain (String[] args)

{

// Given diagonal and angle

intd1 = 3;

intd2 = 5;

inttheta = 90;

// Function call

doublearea = Area_Parallelogram3(

d1, d2, theta);

// Print the area

System.out.format(“%.2f”, area);

}

}

// This code is contributed by offbeat

Python3

# Python3 program for the above approach

importmath

# Function to return the area of

# parallelogram using sides and

# angle at the intersection of diagonal

defArea_Parallelogram1(a, b, theta):

# Calculate area of parallelogram

*abs(a**2-b**2)

returnarea

# Function to return the area of

# parallelogram using sides and

# angle at the intersection of sides

defArea_Parallelogram2(a, b, gamma):

# Calculate area of parallelogram

*abs(a *b)

returnarea

# Function to return the area of

# parallelogram using diagonals and

# angle at the intersection of diagonals

defArea_Parallelogram3(d1, d2, theta):

# Calculate area of parallelogram

*abs(d1 *d2)

returnarea

# Driver Code

# Given diagonal and angle

d1 =3

d2 =5

theta =90

# Function Call

area =Area_Parallelogram3(d1, d2, theta)

# Print the area

print(round(area, 2))

C#

// C# program for

// the above approach

usingSystem;

classGFG{

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of diagonal

staticdoubleArea_Parallelogram1(inta, intb,

inttheta)

{

// Calculate area of parallelogram

doublearea = (Math.Abs(Math.Tan((theta *

Math.PI) / 180)) / 2) *

Math.Abs(a * a – b * b);

returnarea;

}

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of sides

staticdoubleArea_Parallelogram2(inta, intb,

intgamma)

{

// Calculate area of parallelogram

doublearea = (Math.Abs(Math.Sin((gamma *

Math.PI) / 180))) *

Math.Abs(a * b);

returnarea;

}

// Function to return the area of

// parallelogram using diagonals and

// angle at the intersection of diagonals

staticdoubleArea_Parallelogram3(intd1, intd2,

inttheta)

{

// Calculate area of parallelogram

doublearea = (Math.Abs(Math.Sin((theta *

Math.PI) / 180)) / 2) *

Math.Abs(d1 * d2);

returnarea;

}

// Driver code

publicstaticvoidMain(String[] args)

{

// Given diagonal and angle

intd1 = 3;

intd2 = 5;

inttheta = 90;

// Function call

doublearea = Area_Parallelogram3(d1, d2, theta);

// Print the area

Console.Write(“{0:F2}”, area);

}

}

// This code is contributed by Rajput-Ji

Javascript

<script>

// Javascript program for the

// above approach

{

let pi = 3.14159265359;

return(degree * (pi / 180));

}

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of diagonal

functionArea_Parallelogram1(a, b,

theta)

{

// Calculate area of parallelogram

let area = (Math.abs(Math.tan(toRadians(theta))) / 2) *

Math.abs(a * a – b * b);

returnarea;

}

// Function to return the area of

// parallelogram using sides and

// angle at the intersection of sides

functionArea_Parallelogram2(a, b,

gamma)

{

// Calculate area of parallelogram

Math.abs(a * b);

returnarea;

}

// Function to return the area of

// parallelogram using diagonals and

// angle at the intersection of diagonals

functionArea_Parallelogram3(d1, d2,

theta)

{

// Calculate area of parallelogram

let area = (Math.abs(Math.sin(toRadians(theta))) / 2) *

You are watching: Program to calculate area of a parallelogram. Info created by GBee English Center selection and synthesis along with other related topics.