Area of largest Circle that can be inscribed in a SemiCircle - GeeksforGeeks

10 Feb, 2022
Given a semicircle with radius R, the task is to find the area of the largest circle that can be inscribed in the semicircle.Examples:  
Input: R = 2
Output: 3.14

Input: R = 8
Output: 50.24
 
Approach: Let R be the radius of the semicircle 
For Largest circle that can be inscribed in this semicircle, the diameter of the circle must be equal to the radius of the semi-circle.  So, if the radius of the semi-circle is R, then the diameter of the largest inscribed circle will be R.Hence the radius of the inscribed circle must be R/2Therefore the area of the largest circle will be  
For Largest circle that can be inscribed in this semicircle, the diameter of the circle must be equal to the radius of the semi-circle.  
So, if the radius of the semi-circle is R, then the diameter of the largest inscribed circle will be R.
Hence the radius of the inscribed circle must be R/2
Therefore the area of the largest circle will be  
Area of circle = pi*Radius2
               = pi*(R/2)2

since the radius of largest circle is R/2
where R is the radius of the semicircle
 
 
 
Below is the implementation of the above approach:  
C++
Java
Python3
C#
Javascript
// C++ Program to find the biggest circle// which can be inscribed within the semicircle #include <bits/stdc++.h>using namespace std; // Function to find the area// of the circlefloat circlearea(float R){     // Radius cannot be negative    if (R < 0)        return -1;     // Area of the largest circle    float a = 3.14 * R * R / 4;     return a;} // Driver codeint main(){    float R = 2;    cout << circlearea(R) << endl;     return 0;}
// Java Program to find the biggest circle// which can be inscribed within the semicircleclass GFG{         // Function to find the area    // of the circle    static float circlearea(float R)    {             // Radius cannot be negative        if (R < 0)            return -1;             // Area of the largest circle        float a = (float)((3.14 * R * R) / 4);             return a;    }         // Driver code    public static void main (String[] args)    {        float R = 2;        System.out.println(circlearea(R));    }} // This code is contributed by AnkitRai01
# Python3 Program to find the biggest circle# which can be inscribed within the semicircle # Function to find the area# of the circledef circlearea(R) :     # Radius cannot be negative    if (R < 0) :        return -1;     # Area of the largest circle    a = (3.14 * R * R) / 4;     return a; # Driver codeif __name__ == "__main__" :     R = 2;    print(circlearea(R)) ;     # This code is contributed by AnkitRai01
// C# Program to find the biggest circle// which can be inscribed within the semicircleusing System; class GFG{         // Function to find the area    // of the circle    static float circlearea(float R)    {             // Radius cannot be negative        if (R < 0)            return -1;             // Area of the largest circle        float a = (float)((3.14 * R * R) / 4);             return a;    }         // Driver code    public static void Main (string[] args)    {        float R = 2;        Console.WriteLine(circlearea(R));    }} // This code is contributed by AnkitRai01
<script> // Javascript Program to find the biggest circle// which can be inscribed within the semicircle // Function to find the area// of the circlefunction circlearea(R){     // Radius cannot be negative    if (R < 0)        return -1;     // Area of the largest circle    var a = 3.14 * R * R / 4;     return a;} // Driver codevar R = 2;document.write(circlearea(R)); // This code is contributed by rutvik_56.</script>
3.14
 
ankthon
rutvik_56
sagar0719kumar
Geometric
Mathematical
School Programming
Mathematical
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Haversine formula to find distance between two points on a sphere
Equation of circle when three points on the circle are given
Program to find slope of a line
Program to find line passing through 2 Points
Maximum Manhattan distance between a distinct pair from N coordinates
Program for Fibonacci numbers
Write a program to print all permutations of a given string
C++ Data Types
Set in C++ Standard Template Library (STL)
Coin Change | DP-7