- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maximum area of quadrilateral in C++
Problem statement
Given four sides of quadrilateral a, b, c, d, find the maximum area of the quadrilateral possible from the given sides.
Algorithm
We can use below Brahmagupta’s formula to solve this problem −
√(s-a)(s-b)(s-c)(s-d)
In above formula s is semi-perimeter. It is calculated as follows −
S = (a + b + c + d) / 2
Example
Let us now see an example −
#include <bits/stdc++.h> using namespace std; double getMaxArea(double a, double b, double c, double d) { double s = (a + b + c + d) / 2; double area = (s - a) * (s - b) * (s - c) * (s - d); return sqrt(area); } int main() { double a = 1, b = 2.5, c = 1.8, d = 2; cout << "Maximum area = " << getMaxArea(a, b, c, d) << endl; return 0; }
Output
Maximum area = 3.05
- Related Articles
- In the figure, compute the area of the quadrilateral."
- Maximum area of rectangle possible with given perimeter in C++
- Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts in C++
- Maximum area rectangle by picking four sides from array in C++
- C++ Program to get maximum area of rectangle made from line segments
- Find maximum volume of a cuboid from the given perimeter and area in C++
- Maximum of smallest possible area that can get with exactly k cut of given rectangular in C++
- Maximum sub-matrix area having count of 1’s one more than count of 0’s in C++
- Program to find the angles of a quadrilateral in C++
- If $P(2, 1), Q(4, 2), R(5, 4)$ and $S(3, 3)$ are vertices of a quadrilateral $PQRS$, find the area of the quadrilateral $PQRS$.
- Find the area of quadrilateral ABCD, whose vertices are: $A( -3, -1) , B( -2, -4) , C( 4, -1)$ and$ D( 3, 4) .$
- C++ program to find fourth side of a quadrilateral
- Maximum sub-matrix area having count of 1's one more than count of 0’s in C++ program
- Find the area of the quadrilateral ABCD. Here, AC = 22 cm, BM = 3 cm,DN = 3 cm
- Maximum Number of Ones in C++

Advertisements