Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Program to calculate the Area and Perimeter of Incircle of an Equilateral TrianglenWhat is Equilateral Triangle in C?
In C programming, calculating the area and perimeter of an incircle (inscribed circle) of an equilateral triangle involves using specific mathematical formulas. The incircle is the largest circle that can fit inside the triangle, touching all three sides.
What is an Equilateral Triangle?
An equilateral triangle has three equal sides and three equal interior angles of 60° each. It is also known as a regular triangle because it's a regular polygon.
Properties of equilateral triangle are −
- 3 sides of equal length
- Interior angles of same degree which is 60°
Incircle
An incircle is the circle that lies inside the triangle, touching all three sides. The center of the incircle is called the incenter, and its radius is called the inradius.
Syntax
float area = (side * side * ?) / 12; float perimeter = ? * (side / ?3);
Formulas
To calculate area and perimeter of an incircle inside an equilateral triangle, we use these formulas −
-
Area of incircle:
(side² × ?) / 12 -
Perimeter of incircle:
? × (side / ?3)
Example
Here's a complete program to calculate the area and perimeter of an incircle −
#include <stdio.h>
#include <math.h>
#define PI 3.14159
// Function to find area of inscribed circle
float area(float side) {
return (side * side * PI) / 12;
}
// Function to find perimeter of inscribed circle
float perimeter(float side) {
return PI * (side / sqrt(3));
}
int main() {
float side = 6.0;
printf("Side of equilateral triangle: %.1f<br>", side);
printf("Area of inscribed circle: %.6f<br>", area(side));
printf("Perimeter of inscribed circle: %.6f<br>", perimeter(side));
return 0;
}
Side of equilateral triangle: 6.0 Area of inscribed circle: 9.424773 Perimeter of inscribed circle: 10.995562
How It Works
- The
area()function calculates the area using the formula(side² × ?) / 12 - The
perimeter()function calculates the perimeter using? × (side / ?3) - We use
sqrt(3)from themath.hlibrary to calculate the square root
Conclusion
Calculating the incircle properties of an equilateral triangle in C involves applying specific geometric formulas. The incircle area and perimeter depend directly on the triangle's side length and mathematical constants like ? and ?3.
