计算八边形面积的程序
八边形是具有八个边的多边形。要计算八边形的面积,请使用以下公式,
八边形的面积=((a2*2)/*tan(22.5°))=((2*a*a)(1+√2))
代码逻辑,使用上述公式计算具有八个边的多边形的面积。该表达式使用sqrt函数查找2的平方根。该表达式的值被评估为浮点值,该值被放入float区域变量中。
示例
#include <stdio.h>
#include <math.h>
int main(){
int a = 7;
float area;
float multiplier = 6.18;
printf("Program to find area of octagon \n");
printf("The side of the octagon is %d \n", a);
area = ((2*a*a)*(1 + sqrt(2)));
printf("The area of Enneagon is %f \n", area);
return 0;
}输出结果
Program to find area of octagon The side of the octagon is 7 The area of Enneagon is 236.592926
热门推荐
10 父亲简短结婚祝福语大全
11 新年祝福语长辈简短红包
12 年底拜年祝福语大全简短
13 老同学十一祝福语简短
14 中秋祝福语简短版大全
15 给老人的祝福语简短
16 生日祝福语简短激励女生
17 化学老师元旦祝福语简短
18 新年简单祝福语简短好看