C用Program for Program查找一个圆的面积?
面积是表示二维图形范围的数量。圆的面积是该圆在二维平面中所覆盖的面积。
为了找到一个圆的面积,需要半径[r]或直径[d](2*半径)。
用于计算面积的公式为(π*r2)或{(π*d2)/4}。
范例程式码
使用半径查找圆的面积。
#include <stdio.h>
int main(void) {
float pie = 3.14;
int radius = 6;
printf("The radius of the circle is %d \n" , radius);
float area = (float)(pie* radius * radius);
printf("The area of the given circle is %f", area);
return 0;
}输出结果
The radius of the circle is 6 The area of the given circle is 113.040001
范例程式码
使用math.h库使用半径查找圆的面积。它使用数学类的pow函数查找给定数字的平方。
#include <stdio.h>
int main(void) {
float pie = 3.14;
int radius = 6;
printf("The radius of the circle is %d \n" , radius);
float area = (float)(pie* (pow(radius,2)));
printf("The area of the given circle is %f", area);
return 0;
}输出结果
The radius of the circle is 6 The area of the given circle is 113.040001
范例程式码
使用直径查找圆的面积。
#include <stdio.h>
int main(void) {
float pie = 3.14;
int Diameter = 12;
printf("The Diameter of the circle is %d \n" , Diameter);
float area = (float)((pie* Diameter * Diameter)/4);
printf("The area of the given circle is %f", area);
return 0;
}输出结果
The Diameter of the circle is 12 The area of the given circle is 113.040001
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短