任务代码:
#include <stdio.h>
#define PI 3.1415926
int main()
{
float r,d,c,a,sq,v;
printf("please enter the r :");
scanf("%f",&r);
d = 2*r;
c = 2*PI*r;
a = PI*r*r;
sq = 4*PI*r*r;
v=4/3*PI*r*r;
printf("the diameter of the circualr is : %f\n",d);
printf("the circumference of the cicular is : %f\n",c);
printf("the area of the circular is : %f\n",a);
printf("the surface area of the ball is: %f\n",sq);
printf("the volume of the ball is: %f\n",v);
return 0;
}
执行情况:
知识总结:
千万记住printf()中没有&符号,scanf()中才有&符号,所以避免错误,define 是对定义常量的有效使用方法,维护性高,而且可读性好!
心得体会:
在结束了期末考试之后,ocatve 的写法和c语言不太一样,这个假期重新捡起c语言来,励志暑假学完c!