#includeusingnamespacestd;floatarea(floatA){//Aisthesideofthetriangle if(A<0)//ifthevalueisne"/> #includeusingnamespacestd;floatarea(floatA){//Aisthesideofthetriangle if(A<0)//ifthevalueisne">

Home  >  Article  >  Backend Development  >  In a C program, translate the following into Chinese: What is the area of ​​a square inscribed in a circle inscribed in an equilateral triangle?

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

WBOY
WBOYforward
2023-08-31 12:25:08963browse

Here we will see that the area of ​​a square is inscribed in a circle, and that the circle is inscribed in an equilateral triangle. The side of the square is "a". The radius of the circle is "r" and the side of the hexagon is "A". The chart is shown below.

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

#We know that the radius of the inscribed circle of an equilateral triangle is the inner radius of the triangle. So the value is -

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

so the diagonal of the square is -

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

so the area of ​​the square is -

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

Example

#include <iostream>
#include <cmath>
using namespace std;
float area(float A) { //A is the side of the triangle
   if (A < 0) //if the value is negative it is invalid
      return -1;
   float d = A / sqrt(3);
   float area = 0.5*d*d;
   return area;
}
int main() {
   float side = 10;
   cout << "Area is: " << area(side);
}

Output

Area is: 16.6667

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 an equilateral triangle?. 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