Home >Backend Development >C++ >In a C program, translate the following into Chinese: What is the area of ​​a decagon depicted in a circle?

In a C program, translate the following into Chinese: What is the area of ​​a decagon depicted in a circle?

WBOY
WBOYforward
2023-09-09 11:49:021272browse

In a C program, translate the following into Chinese: What is the area of ​​a decagon depicted in a circle?

A regular decagon is a decagon with all sides and angles equal. Here we need to use the radius r of the circle to find the area of ​​the decagon inscribed in the circle,

The mathematical formula for the side of the decagon inscribed in the circle,

a = r&radic;(2-2cos36<sup>o</sup>)

(using the cosine rule )

The formula for finding the area of ​​a decagon,

Area = 5*a<sup>2</sup>*(&radic;5+2&radic;5)/2
Area = 5 *(r&radic;(2-2cos36))^<sup>2</sup>*(&radic;5+2&radic;5)/2
Area = (5r<sup>2</sup>*(3-&radic;5)*(&radic;5+2&radic;5))/4

Use this formula in the program,

Example

#include <stdio.h>
#include <math.h>
int main() {
   float r = 8;
   float area = (5 * pow(r, 2) * (3 - sqrt(5))* (sqrt(5) + (2 * sqrt(5))))/ 4;
   printf("area = %f",area);
   return 0;
}

Output

area = 409.968933

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