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

 

学习总结

 

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):

 1 #include <stdio.h>

 2 

 3 int main(void){

 4         char type;

 5         double height;

 6 

 7         printf("please choose changeType(f/c):");

 8         scanf("%c",&type);

 9         if(type=='f'){

10                 printf("please enter your height(cm):");

11                 scanf("%lf",&height);

12                 printf("your height is %.2f ft.\n",height/2.4);

13         }else if(type=='c'){

14                 printf("please enter your height(ft):");

15                 scanf("%lf",&height);

16                 printf("your height is %.2f cm.\n",height*2.4);

17         }else{

18                 printf("wrong type!\n");

19         }

20 }

 

你可能感兴趣的:(Prim)