C语言:数据类型数据常量

任务代码:

#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!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值