C语言每日题目(打卡第二天)

1.设圆半径r=1.5,圆柱搞h=3,求圆周长,圆面积,圆球表面积,圆球体积,圆柱体体积。用scanf输入数据,输出计算结果,输出时要求有文字说明,取小数点后2位数字;
PI=3.1415926
#include
int main()
{
#define PI 3.1415926
int h;
float r,area=0,perimeter=0,roundPerimeter=0,roundArea=0,cylinderVolume=0;
printf(“please input r&h\n”);
scanf("%f\n",&r);
scanf("%d",&h);
perimeter=2 * PI * r;
printf(“圆周长为%0.2f\n”,perimeter);
area=PIrr;
printf(“圆面积为%0.2f\n”,area);
roundPerimeter=4 * PI * r * r;
printf(“圆球表面积为%0.2f\n”,roundPerimeter);
roundArea= 3.0/4.0 * PI * r* r * r;
printf(“圆球体积为%0.2f\n”,roundArea);
cylinderVolume =area*h;
printf(“圆柱体积为%0.2f\n”,cylinderVolume);
return 0;
} C语言每日题目(打卡第二天)_第1张图片

你可能感兴趣的:(C语言每日题目(打卡第二天))