Skip to content
Related Articles

Related Articles

Area of largest Circle that can be inscribed in a SemiCircle
  • Last Updated : 01 Apr, 2020

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

  1. 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.
  2. So, if the radius of the semi-circle is R, then the diameter of the largest inscribed circle will be R.
  3. Hence the radius of the inscribed circle must be R/2
  4. 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++

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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 circle
float 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 code
int main()
{
    float R = 2;
    cout << circlearea(R) << endl;
  
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to find the biggest circle
// which can be inscribed within the semicircle
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;
        System.out.println(circlearea(R));
    }
}
  
// This code is contributed by AnkitRai01

chevron_right


Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python3 Program to find the biggest circle
# which can be inscribed within the semicircle
  
# Function to find the area
# of the circle
def 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 code
if __name__ == "__main__" :
  
    R = 2;
    print(circlearea(R)) ;
      
# This code is contributed by AnkitRai01

chevron_right


C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# Program to find the biggest circle
// which can be inscribed within the semicircle
using 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

chevron_right


Output:

3.14

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :