数据类型 char //字符数据类型 short //短整型 int //整型 long //长整型 long long //更长的整型 float //单精度浮点数 double //双精度浮点数 %c--打印字符 %d--打印整型 %f--打印浮点型 5lf--打印双精度浮点型 %p--以地址的形式打印 %x--打印十六进制数字

打印字符A #include<stdio.h> int main() { char ch = 'A'; printf("%c\n",ch); //存放字符 char ch = 'A' //%c--打印字符格式的数据 return 0; }

打印整型年龄20 #include<stdio.h> int main() { int Age = 20; printf(“%d\n”,Age); //%d--打印整型十进制数据 return 0; } C中计算数据类型字节 #include<stdio.h> int main(); { printf("%d\n",sizeof(char)); //1byte printf("%d\n",sizeof(short)); // 2 printf("%d\n",sizeof(int)); // 4 printf("%d\n",sizeof(long)); //4/8 //long 必须>=int . int = 4 所以Long4/8都行 //必要时用定义变量float防止报错,如:float weight = 44.2f; printf("%d\n",sizeof(long long)); //8 printf("%d\n",sizeof(float)); //4 printf("%d\n",sizeof(double)); //8 return 0; }