Area of Equilateral triangle inscribed in a Circle of radius R

Given an integer R which denotes the radius of a circle, the task is to find the area of an equilateral triangle inscribed in this circle.

Examples:

Input: R = 4
Output: 20.784
Explanation:
Area of equilateral triangle inscribed in a circle of radius R will be 20.784, whereas side of the triangle will be 6.928

Input: R = 7
Output: 63.651
Explanation:
Area of equilateral triangle inscribed in a circle of radius R will be 63.651, whereas side of the triangle will be 12.124

Approach: Let the above triangle shown be an equilateral triangle denoted as PQR.



Below is the implementation of the above approach:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ implementation to find
// the area of the equilateral triangle
// inscribed in a circle of radius R
#include <iostream>
using namespace std;
  
// Function to find the area of
// equilateral triangle inscribed
// in a circle of radius R
double area(int R) {
       
     // Base and Height of
    // equilateral triangle
    double base = 1.732 * R; 
    double height = (1.5) * R;
       
            // Area using Base and Height
    double area = 0.5 * base * height;
    return area;
}
  
// Driver Code
int main()
{
    int R = 7;
    cout<<(area(R));
    return 0;
}
  
// This code is contributed by 29AjayKumar
chevron_right

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java implementation to find
// the area of the equilateral triangle
// inscribed in a circle of radius R
class GFG
{
    // Function to find the area of
    // equilateral triangle inscribed
    // in a circle of radius R
    static double area(int R) {
          
                // Base and Height of
        // equilateral triangle
        double base = 1.732 * R; 
        double height = (1.5) * R;
          
                // Area using Base and Height
        double area = 0.5 * base * height;
        return area;
    }
  
    // Driver code
    public static void main(String[] args) {
        int R = 7;
        System.out.println(area(R));
  
    }
}
  
// This code is contributed by 29AjayKumar
chevron_right

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python 3 implementation to find
# the area of the equilateral triangle
# inscribed in a circle of radius R
  
# Function to find the area of 
# equilateral triangle inscribed
# in a circle of radius R
def area(R):
    # Base and Height of 
    # equilateral triangle
    base = 1.732 * R
    height = ( 3 / 2 ) * R
      
    # Area using Base and Height
    area = (( 1 / 2 ) * base * height )
    return area
      
# Driver Code
if __name__=='__main__':
    R = 7
    print(area(R))
chevron_right

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# implementation to find
// the area of the equilateral triangle
// inscribed in a circle of radius R
using System;
  
class GFG
{
    // Function to find the area of
    // equilateral triangle inscribed
    // in a circle of radius R
    static double area(int R) 
    {
          
        // Base and Height of
        // equilateral triangle
        double Base = 1.732 * R; 
        double height = (1.5) * R;
          
        // Area using Base and Height
        double area = 0.5 * Base * height;
        return area;
    }
  
    // Driver code
    public static void Main(String[] args)
    {
        int R = 7;
        Console.WriteLine(area(R));
    }
}
  
// This code is contributed by 29AjayKumar
chevron_right

Output:
63.651

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.




Recommended Posts:


Check out this Author's contributed articles.

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.



Improved By : 29AjayKumar

Article Tags :
Practice Tags :