Given an ellipse, with major and minor axis length 2a & 2b respectively. The task is to find the area of the largest circle that can be inscribed in it.
Examples:
Input : a = 5, b = 3
Output : 28.2743
Input : a = 10, b = 8
Output : 201.062

Approach : The maximal radius of the circle inscribed in the ellipse is the minor axis of the ellipse.
So, area of the largest circle = ? * b * b.
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
#define pi 3.1415926
double areaCircle( double b)
{
double area = pi * b * b;
return area;
}
int main()
{
double a = 10, b = 8;
cout << areaCircle(b);
return 0;
}
|
Java
class GFG
{
static double areaCircle( double b)
{
double area = ( double ) 3.1415926 * b * b;
return area;
}
public static void main(String args[])
{
float a = 10 ,b = 8 ;
System.out.println(areaCircle(b)) ;
}
}
|
Python3
import math
def areaCircle(b):
area = math.pi * b * b
return area
a = 10
b = 8
print (areaCircle(b))
|
C#
using System;
class GFG
{
static double areaCircle( double b)
{
double area = ( double )3.1415926 * b * b;
return area;
}
public static void Main()
{
float b = 8;
Console.WriteLine(areaCircle(b)) ;
}
}
|
PHP
<?php
$GLOBALS [ 'pi' ] = 3.1415926;
function areaCircle( $b )
{
$area = $GLOBALS [ 'pi' ] * $b * $b ;
return $area ;
}
$a = 10;
$b = 8;
echo round (areaCircle( $b ), 3);
?>
|
Javascript
<script>
function areaCircle(b)
{
let area = 3.1415926 * b * b;
return area;
}
let a = 10, b = 8;
document.write(areaCircle(b));
</script>
|
Time Complexity: O(1)
Auxiliary Space: O(1)