Maximum area of rectangle possible with given perimeter Last Updated : 01 Aug, 2022 Comments Improve Suggest changes Like Article Like Report Given the perimeter of a rectangle, the task is to find the maximum area of a rectangle which can use n-unit length as its perimeter. Note: Length and Breadth must be an integral value. Example: Input: perimeter = 15 Output: Maximum Area = 12 Input: perimeter = 16 Output: Maximum Area = 16 Approach: For area to be maximum of any rectangle the difference of length and breadth must be minimal. So, in such case the length must be ceil (perimeter / 4) and breadth will be floor(perimeter /4). Hence the maximum area of a rectangle with given perimeter is equal to ceil(perimeter/4) * floor(perimeter/4). Below is the implementation of the above approach: C++ // C++ to find maximum area rectangle #include <bits/stdc++.h> using namespace std; // Function to find max area int maxArea(float perimeter) { int length = (int)ceil(perimeter / 4); int breadth = (int)floor(perimeter / 4); // return area return length * breadth; } // Driver code int main() { float n = 38; cout << "Maximum Area = " << maxArea(n); return 0; } Java //Java to find maximum area rectangle import java.io.*; class GFG { // Function to find max area static int maxArea(float perimeter) { int length = (int)Math.ceil(perimeter / 4); int breadth = (int)Math.floor(perimeter / 4); // return area return length * breadth; } // Driver code public static void main (String[] args) { float n = 38; System.out.println("Maximum Area = " + maxArea(n)); } } Python3 # Python3 program to find # maximum area rectangle from math import ceil, floor # Function to find max area def maxArea(perimeter): length = int(ceil(perimeter / 4)) breadth = int(floor(perimeter / 4)) # return area return length * breadth # Driver code if __name__ == '__main__': n = 38 print("Maximum Area =", maxArea(n)) C# // C# to find maximum area rectangle using System; class GFG { // Function to find max area static int maxArea(float perimeter) { int length = (int)Math.Ceiling(perimeter / 4); int breadth = (int)Math.Floor(perimeter / 4); // return area return length * breadth; } // Driver code public static void Main() { float n = 38; Console.WriteLine("Maximum Area = " + maxArea(n)); } } // This code is contributed // by Akanksha Rai(Abby_akku) PHP <?php // PHP to find maximum area rectangle // Function to find max area function maxArea($perimeter) { $length = (int)ceil($perimeter / 4); $breadth = (int)floor($perimeter / 4); // return area return ($length * $breadth); } // Driver code $n = 38; echo "Maximum Area = " , maxArea($n); // This code is contributed by jit_t ?> JavaScript <script> // JavaScript to find maximum area rectangle // Function to find max area function maxArea(perimeter) { let length = Math.ceil(perimeter / 4); let breadth = Math.floor(perimeter / 4); // return area return length * breadth; } // Driver code let n = 38; document.write("Maximum Area = " + maxArea(n)); // This code is contributed by Manoj. </script> Output: Maximum Area = 90 Time Complexity: O(1)Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Maximum area of rectangle possible with given perimeter S Shivam.Pradhan Follow Improve Article Tags : Mathematical Geometric DSA area-volume-programs Practice Tags : GeometricMathematical Similar Reads Count of maximum distinct Rectangles possible with given Perimeter Given an integer N denoting the perimeter of a rectangle. The task is to find the number of distinct rectangles possible with a given perimeter. Examples Input: N = 10Output: 4Explanation: All the rectangles with perimeter 10 are following in the form of (length, breadth):(1, 4), (4, 1), (2, 3), (3, 3 min read Area and Perimeter of Rectangle in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given the value of the length, breadth, and the task is 2 min read Minimum area of a Polygon with three points given Given three points of a regular polygon(n > 3), find the minimum area of a regular polygon (all sides same) possible with the points given.Examples: Input : 0.00 0.00 1.00 1.00 0.00 1.00 Output : 1.00 By taking point (1.00, 0.00) square is formed of side 1.0 so area = 1.00 . One thing to note in 13 min read Number of rectangles with given area in an N*M grid Given three positive integers N, M, and A, the task is to count the number of rectangles with area equal to A present in an M * N grid. Examples: Input: N = 2, M = 2, A = 2 Output: 4 Explanation: In the given grid of size 2 Ã 2, 2 rectangles of dimension 2 Ã 1 and 2 rectangles of dimension 1 Ã 2 can 10 min read Area of the largest Rectangle without a given point Given the length L and breadth B of a rectangle and the position of a hole in the rectangle as (X, Y) coordinate, the task is to find the area of largest Rectangle within the given Rectangle such that it does not contain the hole.Note: The rectangle is placed at the origin by two of its side touchin 6 min read Area of the largest rectangle possible from given coordinates Given two arrays arr1[] and arr2[] of N denoting N coordinates of the form (arr1[i], 0) and M positive integers denotingM coordinates of the form (arr2[j], 1) where 1 ? i ? N and 1? j ? M. The task is to find the area of the largest rectangle that can be formed using these coordinates. Print 0 if no 8 min read Maximum Perimeter Triangle from array Given an array arr[] of positive integers. Find out the maximum perimeter of the triangle from the array.Note: Return -1, if it is not possible to construct a triangle.Examples:Input: arr[] = [6, 1, 6, 5, 8, 4]Output: 20Explanation: Triangle formed by 8,6 & 6 has perimeter 20, which is the max p 8 min read Program for Area And Perimeter Of Rectangle A rectangle is a flat figure in a plane. It has four sides and four equal angles of 90 degree each. In rectangle all four sides are not of equal length like square, sides opposite to each other have equal length. Both diagonals of the rectangle have equal length. Examples: Input : 4 5 Output : Area 3 min read Find minimum area of rectangle with given set of coordinates Given an array arr of set of points in the X-Y plane. The task is to find the minimum area of a rectangle that can be formed from these points. The sides of the rectangle should be parallel to the X and Y axes. If a rectangle cannot be formed with the given points then print 0 .Examples: Input: arr[ 5 min read Maximum given sized rectangles that can be cut out of a sheet of paper Given the length L and breadth B of a sheet of paper, the task is to find the maximum number of rectangles with given length l and breadth b that can be cut from this sheet of paper.Examples: Input: L = 5, B = 2, l = 14, b = 3 Output: 0 The sheet is smaller than the required rectangle. So, no rectan 6 min read Like