编写c语言程序,输入半径和高度,计算并输出圆周长 圆面积 球体积 圆柱体表面积

2024-11-18 06:06:00
推荐回答(1个)
回答1:

#include

#define   pi  3.1415926

int main(void)

{

double r,h;

double cperimeter,carea,bperimeter,bvolume;

double circleperimeter(double r);

double circlearea(double r);

double ballvolume(double r);

double ballperimeter(double r,double h);

printf("enter the r:");

scanf("%lf",&r);

printf("enter the height:");

scanf("%lf",&返历h);

cperimeter=circleperimeter(r);

carea=circlearea(r);

bperimeter=ballperimeter(r,h);

bvolume=ballvolume(r);

printf("the circle perimeter =%lf\n",cperimeter);

printf("the circle area=%lf\n",carea);

printf("the ball of volume =%lf\t\n",bvolume);

printf("the ball of perimeter =%lf\t\t",bperimeter);

return 0;

 }

 double circleperimeter(double r)

 {

 

  double item;

  item=2*pi*r;

 

  return item;

  } 漏租搜

  double circlearea(double r)

 型贺 {

  double result;

  result=pi*r;

  return result;

  }

  double ballvolume(double r)

  {

  double volume;

  volume= (4*pi*r*r*r)/3;

  return volume;

 

}

double ballperimeter(double r,double h)

{

double ballperimeter;

ballperimeter=4*r*pi+2*pi*r*h;

return ballperimeter;

}