C语言编程的题

来源:百度知道 编辑:UC知道 时间:2024/06/18 12:40:26
设半圆半径r=1.5,圆柱高h=3,求圆周长,圆面积,圆球表面积,圆柱体积。用scanf输入数据,输出计算结果,输出时要求有文字说明,取小数点后两位。请写出编程。

知道圆柱的底面半径r和高h。求圆周长d,圆面积s,圆球表面积S,圆柱体积V。用scanf输入r和h,结果保留2位小数。
#include <stdio.h>
#include <math.h>
#include <conio.h>
main()
{
float r,h,pi,d,s,S,V;
pi=3.1415926;
printf("圆柱的底面半径r和高h:");
scanf("%f,%f",&r,&h);/*输入数据时以逗号隔开r和h*/
d=2*pi*r;
s=pi*r*r;
S=4*pi*r*r*r;
V=pi*r*r*h;
printf("圆周长为d=%.2f\n",d);
printf("圆面积s=%.2f\n",s);
printf("圆球表面积S=%.2f\n",S);
printf("圆球体积V=%.2f\n",V);
getch();
}

知道圆柱的底面半径r和高h。求圆周长d,圆面积s,圆球表面积S,圆柱体积V。用scanf输入r和h,结果保留2位小数。
#include <stdio.h>
#include <math.h> /* power() */
#include <conio.h>/* getch() */
#define PI 3.14
main()
{
float r, h, d, s, S, v, V;
printf("请输入半径:");
scanf("%f", &r);
printf("请输入柱高:");
scanf("%f", &h);
d = 2 * PI * r;