Given a rectangle of dimensions **L** and **W**. The task is to find the maximum area of a rectangle that can be circumscribed about a given rectangle with dimensions **L** and **W**.

**Examples:**

Input:L = 10, W = 10Output:200

Input:L = 18, W = 12Output:450

**Approach:** Let below is the given rectangle **EFGH** of dimensions **L** and **W**. We have to find the area of rectangle **ABCD** which is circumscribing rectangle **EFGH**.

In the above figure:

If then as GCF is right angled triangle.

Therefore,

=>

=>

Similarly,

Now, The area of rectangle ABCD is given by:

Area = AB * AD

Area = (AE + EB)*(AH + HD) …..(1)

According to the projection rule:

AE = L*sin(X)

EB = W*cos(X)

AH = L*cos(X)

HD = W*sin(X)

Substituting the value of the above projections in equation (1) we have:

Now to maximize the area, the value of sin(2X) must be maximum i.e., 1.

Therefore after substituting sin(2X) as 1 we have,

Below is the implementation of the above approach:

## C++

`// C++ program for the above approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find area of rectangle ` `// inscribed another rectangle of ` `// length L and width W ` `double` `AreaofRectangle(` `int` `L, ` `int` `W) ` `{ ` ` ` ` ` `// Area of rectangle ` ` ` `double` `area = (W + L) * (W + L) / 2; ` ` ` ` ` `// Return the area ` ` ` `return` `area; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` ` ` `// Given dimensions ` ` ` `int` `L = 18; ` ` ` `int` `W = 12; ` ` ` ` ` `// Function call ` ` ` `cout << AreaofRectangle(L, W); ` ` ` `return` `0; ` `} ` ` ` `// This code is contributed by Princi Singh ` |

*chevron_right*

*filter_none*

## Java

`// Java program for the above approach ` `import` `java.io.*; ` `import` `java.util.*; ` ` ` `class` `GFG{ ` ` ` `// Function to find area of rectangle ` `// inscribed another rectangle of ` `// length L and width W ` `static` `double` `AreaofRectangle(` `int` `L, ` `int` `W) ` `{ ` ` ` ` ` `// Area of rectangle ` ` ` `double` `area = (W + L) * (W + L) / ` `2` `; ` ` ` ` ` `// Return the area ` ` ` `return` `area; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `main(String args[]) ` `{ ` ` ` ` ` `// Given dimensions ` ` ` `int` `L = ` `18` `; ` ` ` `int` `W = ` `12` `; ` ` ` ` ` `// Function call ` ` ` `System.out.println(AreaofRectangle(L, W)); ` `} ` `} ` ` ` `// This code is contributed by offbeat ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program for the above approach ` ` ` `# Function to find area of rectangle ` `# inscribed another rectangle of ` `# length L and width W ` `def` `AreaofRectangle(L, W): ` ` ` ` ` `# Area of rectangle ` ` ` `area ` `=` `(W ` `+` `L)` `*` `(W ` `+` `L)` `/` `2` ` ` `# Return the area ` ` ` `return` `area ` ` ` `# Driver Code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `# Given Dimensions ` ` ` `L ` `=` `18` ` ` `W ` `=` `12` ` ` ` ` `# Function Call ` ` ` `print` `(AreaofRectangle(L, W)) ` |

*chevron_right*

*filter_none*

## C#

`// C# program for the above approach ` `using` `System; ` ` ` `class` `GFG{ ` ` ` `// Function to find area of rectangle ` `// inscribed another rectangle of ` `// length L and width W ` `static` `double` `AreaofRectangle(` `int` `L, ` `int` `W) ` `{ ` ` ` ` ` `// Area of rectangle ` ` ` `double` `area = (W + L) * (W + L) / 2; ` ` ` ` ` `// Return the area ` ` ` `return` `area; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main(String []args) ` `{ ` ` ` ` ` `// Given dimensions ` ` ` `int` `L = 18; ` ` ` `int` `W = 12; ` ` ` ` ` `// Function call ` ` ` `Console.Write(AreaofRectangle(L, W)); ` `} ` `} ` ` ` `// This code is contributed by shivanisinghss2110 ` |

*chevron_right*

*filter_none*

**Output:**

450.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:

- Ratio of area of a rectangle with the rectangle inscribed in it
- Maximum area of rectangle possible with given perimeter
- Rectangle with Maximum Area using Java Pair
- Number of squares of maximum area in a rectangle
- Maximum area of rectangle inscribed in an equilateral triangle
- Maximum area rectangle by picking four sides from array
- Length and Breadth of rectangle such that ratio of Area to diagonal^2 is maximum
- Area and Perimeter of Rectangle in PL/SQL
- Largest subset of rectangles such that no rectangle fit in any other rectangle
- Find the number of rectangles of size 2*1 which can be placed inside a rectangle of size n*m
- Sum of Area of all possible square inside a rectangle
- Area of the largest Rectangle without a given point
- Program for Area And Perimeter Of Rectangle
- Area of Largest rectangle that can be inscribed in an Ellipse
- Area of the biggest possible rhombus that can be inscribed in a rectangle
- Find minimum area of rectangle with given set of coordinates
- Find the percentage change in the area of a Rectangle
- Area of largest triangle that can be inscribed within a rectangle
- Area of the biggest ellipse inscribed within a rectangle
- Count the number of rhombi possible inside a rectangle of given size

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.