Home > Backend Development > C++ > body text

In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular hexagon?

王林
Release: 2023-09-05 21:33:09
forward
992 people have browsed it

Here we will see the area of a square which in inscribed in one circle and that circle is inscribed in a hexagon. The side of the square is ‘a’. The radius of the circle is ‘r’, and the side of the hexagon is ‘A’. The diagram will be like below.

In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular hexagon?

We know that the radius of a circle inscribed in a hexagon is −

In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular hexagon?

Also the radius of the circle is half of the diagonal of the square. So −

In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular hexagon?

Then we can say −

In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular hexagon?

Then the area will be −

In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular hexagon?

Example

#include <iostream>
#include <cmath>
using namespace std;
float area(float A) { //A is the side of the hexagon
   if (A < 0) //if the value is negative it is invalid
      return -1;
   float area = (A*A) * float(3.0/2.0);
   return area;
}
int main() {
   float side = 5;
   cout << "Area is: " << area(side);
}
Copy after login

输出

Area is: 37.5
Copy after login

The above is the detailed content of In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in a regular 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