请看下我的程序哪里错了..

来源:百度知道 编辑:UC知道 时间:2024/09/22 03:52:56
#include<stdio.h>
#define PI=3.1415927
main()
{
float a,volume;
printf("input the radium of global:\n");
scanf("%f\n",&a);
volume=4*PI*a*a*a/3;
printf("the volume of the global is %f\n",volume);
return 0;
}
请说明下为什么这样改,我初学

(1)#define PI=3.1415927 should be modified to #define PI 3.1415927
you can not add assignment notation after variable constant it will replace PI with "=3.1415927", of course, "=3.1415927" will cause mistake in you mathematic operation
(2)scanf("%f\n",&a)
I don't think it's a good to use \n here, it's absolutely useless, and make you input twice for variable a

volume=4*PI*a*a*a/3; 改成volume=4*PI*a*a*a/3.0;