计算八边形面积的程序
八边形是具有八个边的多边形。要计算八边形的面积,请使用以下公式,
八边形的面积=((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 官宣新年祝福语简短