Program to calculate area of a parallelogram
Last Updated :
05 Apr, 2021
Given integers A and B denoting the length of sides of a parallelogram and Y that 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>
using namespace std;
double toRadians(int degree)
{
double pi = 3.14159265359;
return ((double)degree * (pi / 180));
}
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of diagonal
double Area_Parallelogram1(int a, int b,
int theta)
{
// Calculate area of parallelogram
double area = (abs(tan(toRadians(theta))) / 2) *
abs(a * a - b * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of sides
double Area_Parallelogram2(int a, int b,
int gamma)
{
// Calculate area of parallelogram
double area = (abs(sin(toRadians(gamma)))) *
abs(a * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using diagonals and
// angle at the intersection of diagonals
static double Area_Parallelogram3(int d1, int d2,
int theta)
{
// Calculate area of parallelogram
double area = (abs(sin(toRadians(theta))) / 2) *
abs(d1 * d2);
// Return the answer
return area;
}
// Driver Code
int main()
{
// Given diagonal and angle
int d1 = 3;
int d2 = 5;
int theta = 90;
// Function call
double area = Area_Parallelogram3(d1,
d2,
theta);
// Print the area
printf("%.2f", area);
}
// This code is contributed by rutvik_56
Java
// Java program for above approach
import java.io.*;
class GFG{
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of diagonal
static double Area_Parallelogram1(int a, int b,
int theta)
{
// Calculate area of parallelogram
double area = (Math.abs(Math.tan(
Math.toRadians(theta))) / 2) *
Math.abs(a * a - b * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of sides
static double Area_Parallelogram2(int a, int b,
int gamma)
{
// Calculate area of parallelogram
double area = (Math.abs(Math.sin(
Math.toRadians(gamma)))) *
Math.abs(a * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using diagonals and
// angle at the intersection of diagonals
static double Area_Parallelogram3(int d1, int d2,
int theta)
{
// Calculate area of parallelogram
double area = (Math.abs(Math.sin(
Math.toRadians(theta))) / 2) *
Math.abs(d1 * d2);
// Return the answer
return area;
}
// Driver code
public static void main (String[] args)
{
// Given diagonal and angle
int d1 = 3;
int d2 = 5;
int theta = 90;
// Function call
double area = 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
import math
# Function to return the area of
# parallelogram using sides and
# angle at the intersection of diagonal
def Area_Parallelogram1(a, b, theta):
# Calculate area of parallelogram
area = (abs(math.tan(math.radians(theta)))/2) \
* abs(a**2 - b**2)
# Return the answer
return area
# Function to return the area of
# parallelogram using sides and
# angle at the intersection of sides
def Area_Parallelogram2(a, b, gamma):
# Calculate area of parallelogram
area = (abs(math.sin(math.radians(gamma)))) \
* abs(a * b)
# Return the answer
return area
# Function to return the area of
# parallelogram using diagonals and
# angle at the intersection of diagonals
def Area_Parallelogram3(d1, d2, theta):
# Calculate area of parallelogram
area = (abs(math.sin(math.radians(theta)))/2) \
* abs(d1 * d2)
# Return the answer
return area
# 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
using System;
class GFG{
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of diagonal
static double Area_Parallelogram1(int a, int b,
int theta)
{
// Calculate area of parallelogram
double area = (Math.Abs(Math.Tan((theta *
Math.PI) / 180)) / 2) *
Math.Abs(a * a - b * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of sides
static double Area_Parallelogram2(int a, int b,
int gamma)
{
// Calculate area of parallelogram
double area = (Math.Abs(Math.Sin((gamma *
Math.PI) / 180))) *
Math.Abs(a * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using diagonals and
// angle at the intersection of diagonals
static double Area_Parallelogram3(int d1, int d2,
int theta)
{
// Calculate area of parallelogram
double area = (Math.Abs(Math.Sin((theta *
Math.PI) / 180)) / 2) *
Math.Abs(d1 * d2);
// Return the answer
return area;
}
// Driver code
public static void Main(String[] args)
{
// Given diagonal and angle
int d1 = 3;
int d2 = 5;
int theta = 90;
// Function call
double area = 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
function toRadians(degree)
{
let pi = 3.14159265359;
return (degree * (pi / 180));
}
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of diagonal
function Area_Parallelogram1(a, b,
theta)
{
// Calculate area of parallelogram
let area = (Math.abs(Math.tan(toRadians(theta))) / 2) *
Math.abs(a * a - b * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using sides and
// angle at the intersection of sides
function Area_Parallelogram2(a, b,
gamma)
{
// Calculate area of parallelogram
let area = (Math.abs(Math.sin(toRadians(gamma)))) *
Math.abs(a * b);
// Return the answer
return area;
}
// Function to return the area of
// parallelogram using diagonals and
// angle at the intersection of diagonals
function Area_Parallelogram3(d1, d2,
theta)
{
// Calculate area of parallelogram
let area = (Math.abs(Math.sin(toRadians(theta))) / 2) *
Math.abs(d1 * d2);
// Return the answer
return area;
}
// Driver Code
// Given diagonal and angle
let d1 = 3;
let d2 = 5;
let theta = 90;
// Function call
let area = Area_Parallelogram3(d1, d2,
theta);
// Print the area
document.write(area);
// This code is contributed by Mayank Tyagi
</script>
Time Complexity: O(1)
Auxiliary Space: O(1)
Similar Reads
Program to find the Area of a Parallelogram Given the sides of a Parallelogram, task is calculate the area of a Parallelogram. Examples: Input: base = 30, height = 40 Output: 1200.000000 As Area of parallelogram = base * height, Therefore, Area = 30 * 40 = 1200.00 Approach: Area of parallelogram = base * height Below is the implementation of
2 min read
Program to calculate area and perimeter of Trapezium A trapezium is a quadrilateral with at least one pair of parallel sides, other two sides may not be parallel. The parallel sides are called the bases of the trapezium and the other two sides are called it's legs. The perpendicular distance between parallel sides is called height of trapezium. Formul
5 min read
Program to calculate Area Of Octagon A regular octagon is a closed figure with sides of the same length and internal angles of the same size. It has eight lines of reflective symmetry and rotational symmetry of order 8. The internal angle at each vertex of a regular octagon is 135°. The central angle is 45°.Properties : Convex polygon,
3 min read
Program to calculate area of Enneagon Enneagon is a polygon with 9 sides and 9 internal angles. Enneagon is also known as Nonagon. A regular nonagon has an internal angle of 140 degrees each. Sum of interior angles of the nonagon is 1260 degree. The center of the circumcircle is also taken as the center of the regular Nonagon. The line
3 min read
Program to calculate the area of Kite Kite is something like rhombus but in Kite, the adjacent sides are equal and diagonals are generally not equal. Method 1: When both the diagonals are givenIf diagonals d1 and d2 are given of the kite, then the area of a kite is half of product of both the diagonals i.e. \ Area = \frac{ d1 * d2 } {2}
5 min read
Program for Circumference of a Parallelogram Given the sides of Parallelogram then calculate the circumference.Examples : Input: a = 10, b = 8 Output: 36.00 Input: a = 25.12, b = 20.4 Output: 91.04 The opposite sides of a parallelogram are of equal length and parallel. The angles are pairwise equal but not necessarily 90 degree. The circumfere
3 min read