Home  >  Article  >  Backend Development  >  In a C program, what is the area of ​​a hexagon given the length of its diagonal?

In a C program, what is the area of ​​a hexagon given the length of its diagonal?

WBOY
WBOYforward
2023-08-27 10:25:061093browse

In a C program, what is the area of ​​a hexagon given the length of its diagonal?

A hexagon is a closed figure of a hexagon, and a regular hexagon is a hexagon with six equal sides and equal angles. To find the area of ​​a hexagon, we are given only the length of its diagonal, which is d.

Each interior angle of a hexagon is 120 degrees, and the sum of all angles of a hexagon is 720 degrees.

The formula to find the area of ​​a hexagon with side length a,

Area = (3a<sup>2</sup> &radic;3) / 2.

Since all sides are the same size and the angle is 120 degrees,

d = 2a or a = d/2

By changing the value of a Denoted as d, we get the area with respect to d. The Chinese translation of

2 &radic;3 ) / 8

Example

is:

Example

#include <stdio.h>
#include<math.h>
int main() {
   float d = 10;
   float area = (3 * sqrt(3) * pow(d, 2)) / 8;
   printf("Area of hexagon = %f",area);
   return 0;
}

Output

Area of hexagon = 64.951904

The above is the detailed content of In a C program, what is the area of ​​a hexagon given the length of its diagonal?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete