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
Area of a circle inscribed in a regular hexagon?
In C programming, calculating the area of a circle inscribed in a regular hexagon involves understanding the geometric relationship between the hexagon and its inscribed circle. A circle inscribed in a regular hexagon touches all six sides of the hexagon at their midpoints.
Syntax
area = (3 * ? * side * side) / 4
Mathematical Formula
For a regular hexagon with side length a, the radius of the inscribed circle is r = a(?3)/2. Using the circle area formula A = ?r², we get −
The final formula becomes: Area = 3?a²/4
Example
Here's a complete C program to calculate the area of a circle inscribed in a regular hexagon −
#include <stdio.h>
#include <math.h>
int main() {
float side = 14.0;
float pi = 3.14159;
float area = (3 * pi * side * side) / 4;
printf("Side of hexagon: %.1f<br>", side);
printf("Area of inscribed circle: %.2f<br>", area);
return 0;
}
Side of hexagon: 14.0 Area of inscribed circle: 461.81
Example with User Input
This example demonstrates calculating the area with different hexagon side lengths −
#include <stdio.h>
#include <math.h>
int main() {
float sides[] = {4.0, 6.0, 8.0};
float pi = 3.14159;
int i;
printf("Area of inscribed circles:<br>");
printf("Side\tArea<br>");
printf("----\t----<br>");
for (i = 0; i < 3; i++) {
float area = (3 * pi * sides[i] * sides[i]) / 4;
printf("%.1f\t%.2f<br>", sides[i], area);
}
return 0;
}
Area of inscribed circles: Side Area ---- ---- 4.0 37.70 6.0 84.82 8.0 150.80
Key Points
- The inscribed circle's radius is r = a?3/2 where
ais the hexagon side length. - The area formula 3?a²/4 is derived from the standard circle area formula
?r². - Use
math.hlibrary for more precise calculations withM_PIconstant.
Conclusion
Calculating the area of a circle inscribed in a regular hexagon is straightforward using the formula 3?a²/4. This geometric relationship is useful in various engineering and mathematical applications.
