请教学习C语言的高手办忙

来源:百度知道 编辑:UC知道 时间:2024/06/21 11:38:02
如何编写一个程序,调用函数求一个圆柱的表面积和体积?

#include<stdio.h>

#define PI 3.14

float s(float r, float h)
float v(float r, float h)

int main()
{
float r,h;
printf("Please input r and h:");
scanf("%f %f",&r,&h);
printf("The s is %f, and the v is %f",s(r,h),v(r,h));
return 0;
}

float s(float r, float h)
{
return (2*PI*r*r+2*PI*r*h);
}

float v(float r, float h)
{
return (2*PI*r*r*h);
}