Given an ellipse with a semi-major axis of length a and semi-minor axis of length b. The task is to find the area of an ellipse.
In mathematics, an ellipse is a curve in a plane surrounding by two focal points such that the sum of the distances to the two focal points is constant for every point on the curve or we can say that it is a generalization of the circle.

Important points related to Ellipse:
- Center: A point inside the ellipse which is the midpoint of the line segment which links the two foci. In other words, it is the intersection of minor and major axes.
- Major Axis: The longest diameter of an ellipse is termed as the major axis.
- Minor Axis: The shortest diameter of an ellipse is termed as minor axis.
- Chord: A line segment that links any two points on an ellipse.
- Focus: These are the two fixed points that define an ellipse.
- Latus Rectum: The line segments which passes through the focus of an ellipse and perpendicular to the major axis of an ellipse, is called as the latus rectum of an ellipse.
Area of an ellipse: The formula to find the area of an ellipse is given below:
Area = 3.142 * a * b
where a and b are the semi-major axis and semi-minor axis respectively and 3.142 is the value of π.
Examples:
Input : a = 5, b = 4
Output : 62.48
Input : a = 10, b = 5
Output : 157.1
C++
#include<bits/stdc++.h>
using namespace std;
void findArea( float a, float b)
{
float Area;
Area = 3.142 * a * b ;
cout << "Area: " << Area;
}
int main()
{
float a = 5, b = 4;
findArea(a, b);
return 0;
}
|
Java
class GFG {
static void findArea( float a, float b)
{
float Area;
Area = ( float ) 3.142 * a * b ;
System.out.println( "Area: " + Area);
}
public static void main (String[] args)
{
float a = 5 , b = 4 ;
findArea(a, b);
}
}
|
Python3
def findArea(a, b):
Area = 3.142 * a * b ;
print ( "Area:" , round (Area, 2 ));
a = 5 ;
b = 4 ;
findArea(a, b);
|
C#
using System;
class GFG
{
static void findArea( float a,
float b)
{
float Area;
Area = ( float )3.142 * a * b ;
Console.WriteLine( "Area: " +
Area);
}
public static void Main ()
{
float a = 5, b = 4;
findArea(a, b);
}
}
|
PHP
<?php
function findArea( $a , $b )
{
$Area ;
$Area = 3.142 * $a * $b ;
echo "Area: " . $Area ;
}
$a = 5; $b = 4;
findArea( $a , $b );
?>
|
Javascript
<script>
function findArea(a , b) {
var Area;
Area = 3.142 * a * b;
document.write( "Area: " + Area.toFixed(2));
}
var a = 5, b = 4;
findArea(a, b);
</script>
|
Time Complexity: O(1)
Auxiliary Space: O(1)