Given the length of sides of an equilateral triangle, the task is to find the area and perimeter of Incircle of the given equilateral triangle. Examples:
Input: side = 6 Output: Area = 9.4. Perimeter = 10.88 Input: side = 9 Output: Area = 21.21, Perimeter = 16.32
Properties of an Incircle are:
- The center of the Incircle is same as the center of the triangle i.e. the point where the medians of the equilateral triangle intersect.
- Inscribed circle of an equilateral triangle is made through the midpoint of the edges of an equilateral triangle.
- The Inradius of an Incircle of an equilateral triangle can be calculated using the formula:
,
- whereÂ
is the length of the side of equilateral triangle.
- Below image shows an equilateral triangle with incircle:
Â
- Approach: Area of circle =Â
and perimeter of circle =Â
, where r is the radius of given circle. Also the radius of Incircle of an equilateral triangle = (side of the equilateral triangle)/ 3. Therefore,
- The formula used to calculate the area of Incircle using Inradius is:
- The formula used to calculate the perimeter of Incircle using Inradius is:
C
// C program to find the area of Inscribed circle // of equilateral triangle#include <math.h>#include <stdio.h>#define PI 3.14159265   // function to find area of inscribed circlefloat area_inscribed(float a){    return (a * a * (PI / 12));}   // function to find Perimeter of inscribed circlefloat perm_inscribed(float a){    return (PI * (a / sqrt(3)));}   // Driver codeint main(){    float a = 6;    printf("Area of inscribed circle is :%f\n",           area_inscribed(a));       printf("Perimeter of inscribed circle is :%f",           perm_inscribed(a));       return 0;} |
Java
// Java code to find the area of inscribed// circle of equilateral triangleimport java.lang.*;   class GFG {       static double PI = 3.14159265;       // function to find the area of    // inscribed circle    public static double area_inscribed(double a)    {        return (a * a * (PI / 12));    }       // function to find the perimeter of    // inscribed circle    public static double perm_inscribed(double a)    {        return (PI * (a / Math.sqrt(3)));    }       // Driver code    public static void main(String[] args)    {        double a = 6.0;        System.out.println("Area of inscribed circle is :"                           + area_inscribed(a));           System.out.println("\nPerimeter of inscribed circle is :"                           + perm_inscribed(a));    }} |
Python3
# Python3 code to find the area of inscribed # circle of equilateral triangleimport mathPI = 3.14159265Â Â Â Â Â Â Â # Function to find the area of # inscribed circledef area_inscribed(a):Â Â Â Â return (a * a * (PI / 12))Â Â Â # Function to find the perimeter of # inscribed circledef perm_inscribed(a):Â Â Â Â return ( PI * (a / math.sqrt(3) ) )Â Â Â Â Â Â Â Â Â # Driver codea = 6.0print("Area of inscribed circle is :% f"Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % area_inscribed(a))print("\nPerimeter of inscribed circle is :% f"Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % perm_inscribed(a)) |
C#
// C# code to find the area of// inscribed circle// of equilateral triangleusing System;   class GFG {    static double PI = 3.14159265;       // function to find the area of    // inscribed circle    public static double area_inscribed(double a)    {        return (a * a * (PI / 12));    }       // function to find the perimeter of    // inscribed circle    public static double perm_inscribed(double a)    {        return (PI * (a / Math.Sqrt(3)));    }       // Driver code    public static void Main()    {        double a = 6.0;        Console.Write("Area of inscribed circle is :"                      + area_inscribed(a));           Console.Write("\nPerimeter of inscribed circle is :"                      + perm_inscribed(a));    }} |
PHP
<?php// PHP program to find the // area of inscribed // circle of equilateral triangle$PI = 3.14159265;Â Â Â // function to find area of // inscribed circlefunction area_inscribed($a){Â Â Â Â global $PI;Â Â Â Â return ($a * $a * ($PI / 12));}Â Â Â // function to find perimeter of // inscribed circlefunction perm_inscribed($a){Â Â Â Â global $PI;Â Â Â Â return ( $PI * ( $a / sqrt(3) ) );}Â Â Â // Driver code$a = 6;echo("Area of inscribed circle is :");echo(area_inscribed($a));echo("Perimeter of inscribed circle is :");echo(perm_inscribed($a));Â Â Â ?> |
Javascript
Javascrip// JavaScript code to find the area of inscribed // circle of equilateral trianglelet PI = 3.14159265Â Â Â Â Â Â Â // Function to find the area of // inscribed circlefunction area_inscribed(a){Â Â Â Â return (a * a * (PI / 12))}Â Â Â // Function to find the perimeter of // inscribed circlefunction perm_inscribed(a){Â Â Â Â return ( PI * (a / Math.sqrt(3) ) )Â Â Â }Â Â Â Â Â Â // Driver codelet a = 6.0console.log("Area of inscribed circle is :", area_inscribed(a))console.log("\nPerimeter of inscribed circle is :", perm_inscribed(a))Â
// This code is contributed by phasing17. |
Time Complexity: O(1)
Auxiliary Space: O(1)
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!
