Home > Backend Development > C++ > C program to calculate the area of ​​a square within a circle inscribed in a hexagon

C program to calculate the area of ​​a square within a circle inscribed in a hexagon

PHPz
Release: 2023-08-28 20:41:09
forward
1166 people have browsed it

C program to calculate the area of ​​a square within a circle inscribed in a hexagon

Given a square inscribed in a circle inscribed by a regular hexagon, we need to find the area of ​​the square. To do this, we need to find the side length of the square and the sides of the regular hexagon. long relationship.

The mathematical formula for the radius of the inscribed circle of a regular hexagon is, r=A√3/2

Since the diagonal of the square is equal to the diameter of the circle, the distance between the radius and the side length The relationship is, a=√r

According to the side length of the regular hexagon,

a = √3A/√2
Copy after login

So, the area of ​​the square, area=a2 = (√3A/√ 2)2

Example

#include <stdio.h>
#include <math.h>
int main() {
   float a = 5;
   float area = pow((a * sqrt(3)) / (sqrt(2)), 2);
   printf("area = %f", area);
   return 0;
}
Copy after login

Output

area = 37.500000
Copy after login

The above is the detailed content of C program to calculate the area of ​​a square within a circle inscribed in a hexagon. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template