您的位置:首页 > 编程语言 > C语言/C++

【C语言学习】《C Primer Plus》第3章 数据和C

2015-05-18 09:52 323 查看
学习总结

1、C基本数据类型使用11个关键字:int、long、short、unsigned、char、float、double、signed、_Bool、_Complex和_Imaginary。

2、在标准C中,整数0就是false,大于0的整数都为true。char其实也是可以是以整数打印。

3、八进制以0为前缀表示、十六进制以0x或0X表示。

4、可以用过sizeof关键字查询类型的长度,如果sizeof(int)。C99出现了可移植类型(inttype.h):int16_t、unint32_t等,主要还是为了代码的可移植性。

5、编程练习(题7):

#include <stdio.h>

int main(void){
char type;
double height;

printf("please choose changeType(f/c):");
scanf("%c",&type);
if(type=='f'){
printf("please enter your height(cm):");
scanf("%lf",&height);
printf("your height is %.2f ft.\n",height/2.4);
}else if(type=='c'){
printf("please enter your height(ft):");
scanf("%lf",&height);
printf("your height is %.2f cm.\n",height*2.4);
}else{
printf("wrong type!\n");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: