Area of the circumcircle of any triangles with sides given
Given a triangle with known sides a, b and c; the task is to find the area of its circumcircle.
Examples:
Input: a = 2, b = 2, c = 3 Output: 114.834 Input: a = 4, b = 5, c = 3 Output: 314

Approach:
For a triangle with side lengths a, b, and c,
Radius of the circumcircle:![]()
![]()
where A = √(s*(s-a)*(s-b)*(s-c)) and s = (a+b+c)/2 is the semiperimeter. Therefore, Area of the circumcircle:
![]()
Below is the implementation of the above approach:
C++
// C++ Program to find the area // the circumcircle of the given triangle #include <bits/stdc++.h> using namespace std; // Function to find the area // of the circumcircle float circlearea(float a, float b, float c) { // the sides cannot be negative if (a < 0 || b < 0 || c < 0) return -1; // semi-perimeter of the circle float p = (a + b + c) / 2; // area of triangle float At = sqrt(p * (p - a) * (p - b) * (p - c)); // area of the circle float A = 3.14 * pow(((a * b * c) / At), 2); return A; } // Driver code int main() { // Get the sides of the triangle float a = 4, b = 5, c = 3; // Find and print the area of the circumcircle cout << circlearea(a, b, c) << endl; return 0; } |
chevron_right
filter_none
Java
// Java Program to find the area // the circumcircle of the given triangle import java.*; class gfg { // Function to find the area // of the circumcircle public double circlearea(double a, double b, double c) { // the sides cannot be negative if (a < 0 || b < 0 || c < 0) return -1; // semi-perimeter of the circle double p = (a + b + c) / 2; // area of triangle double At = Math.sqrt(p * (p - a) * (p - b) * (p - c)); // area of the circle double A = 3.14 * Math.pow(((a * b * c) / At), 2); return A; } } class geek { // Driver code public static void main(String[] args) { gfg g = new gfg(); // Get the sides of the triangle double a = 4, b = 5, c = 3; // Find and print the area of the circumcircle System.out.println(g.circlearea(a, b, c)); } } //This code is contributed by shk.. |
chevron_right
filter_none
Python3
# Python3 Program to find the area # the circumcircle of the given triangle import math # Function to find the area # of the circumcircle def circlearea(a, b, c): # the sides cannot be negative if (a < 0 or b < 0 or c < 0): return -1; # semi-perimeter of the circle p = (a + b + c) / 2; # area of triangle At = math.sqrt(p * (p - a) * (p - b) * (p - c)); # area of the circle A = 3.14 * pow(((a * b * c) / At), 2); return A; # Driver code # Get the sides of the triangle a = 4; b = 5; c = 3; # Find and print the area # of the circumcircle print (int(circlearea(a, b, c))); print ("\n"); # This code is contributed # by Shivi_Aggarwal |
chevron_right
filter_none
C#
// C# Program to find the area // the circumcircle of the given triangle using System; class gfg { // Function to find the area // of the circumcircle public double circlearea(double a, double b, double c) { // the sides cannot be negative if (a < 0 || b < 0 || c < 0) return -1; // semi-perimeter of the circle double p = (a + b + c) / 2; // area of triangle double At = Math.Sqrt(p * (p - a) * (p - b) * (p - c)); // area of the circle double A = 3.14 * Math.Pow(((a * b * c) / At), 2); return A; } } class geek { // Driver code public static int Main() { gfg g = new gfg(); // Get the sides of the triangle double a = 4, b = 5, c = 3; // Find and print the area of the circumcircle Console.WriteLine(g.circlearea(a, b, c)); return 0; } } //This code os contributed by SoumikMondal |
chevron_right
filter_none
PHP
<?php // PHP Program to find the // area the circumcircle of // the given triangle // Function to find the area // of the circumcircle function circlearea($a, $b, $c) { // the sides cannot be negative if ($a < 0 || $b < 0 || $c < 0) return -1; // semi-perimeter of the circle $p = ($a + $b + $c) / 2; // area of triangle $At = sqrt($p * ($p - $a) * ($p - $b) * ($p - $c)); // area of the circle $A = 3.14 * pow((($a * $b * $c) / $At), 2); return $A; } // Driver code // Get the sides of the triangle $a = 4; $b = 5; $c = 3; // Find and print the area // of the circumcircle echo circlearea($a, $b, $c); // This code os contributed // by inder_verma ?> |
chevron_right
filter_none
Output:
314
Recommended Posts:
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Area of Circumcircle of a Right Angled Triangle
- Find all possible triangles with XOR of sides zero
- Program to calculate area of Circumcircle of an Equilateral Triangle
- Count of acute, obtuse and right triangles with given sides
- Find area of triangle if two vectors of two adjacent sides are given
- Find area of parallelogram if vectors of two adjacent sides are given
- Find all sides of a right angled triangle from given hypotenuse and area | Set 1
- Program to find the Circumcircle of any regular polygon
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Check whether triangle is valid or not if sides are given
- Maximize volume of cuboid with given sum of sides
- Check if it is possible to create a polygon with given n sides
- Find other two sides of a right angle triangle
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.



