C语言:输入圆半径r和圆柱高h,求圆周长、圆面积、圆球体积和圆柱体积

Posted by: NOTEPAD 2015年11月7日 2 Comments

#include <stdio.h>
 
#define PI (3.1415926) // 定义圆周率PI
int main()
{
	float r, h;
 
	printf("请输入半径 r = ");
	scanf("%f", &r);
	printf("请输入圆柱高 h = ");
	scanf("%f", &h);
 
	printf("圆周长 = %.2f\n", 2 * PI * r); // 2 * π * r
	printf("圆面积 = %.2f\n", PI * r * r); // π * (r^2)
	printf("圆球体积 = %.2f\n", PI * r * r * r * 4 / 3.0); // (4/3) * π * (r^3)
	printf("圆柱体积 = %.2f\n", PI * r * r * h); // π * (r^2) * h
 
	return 0;
}
  1. I like this site very much, Its a rattling nice place to read and obtain info.Blog monetyze

  2. magnificent submit, very informative. I’m wondering why the opposite specialists of this sector don’t understand this. You should continue your writing. I’m confident, you’ve a great readers’ base already!

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注