八边形面积计算程序
八边形是一种八边多边形。要计算八边形面积,使用以下公式:
八边形面积 = ((a2*2) / *tan (22.5°)) = ((2*a*a)(1+√2))
代码逻辑,使用上面的公式计算八边多边形面积。表达式使用 sqrt 函数来查找 2 的平方根。表达式的值以浮点值计算,然后放入浮点面积变量中。
示例
#include <stdio.h>
#include <math.h>
int main(){
int a = 7;
float area;
float multiplier = 6.18;
printf("Program to find area of octagon
");
printf("The side of the octagon is %d
", a);
area = ((2*a*a)*(1 + sqrt(2)));
printf("The area of Enneagon is %f
", area);
return 0;
}输出
Program to find area of octagon The side of the octagon is 7 The area of Enneagon is 236.592926
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP