#include <stdio.h>
#include <limits.h>
#include <float.h>
void main()
{
//int
int i = INT_MIN, i1 = INT_MAX;
printf("int:\n \t%d..%d\n",i,i1);
printf("\t所占字节:%d\n\n",sizeof(int));
//float
float f = FLT_MIN, f1 = FLT_MAX;
printf("float:\n \t%e..%e\n\n",f,f1);
printf("\t所占字节:%d\n\n",sizeof(float));
//double
double d = DBL_MIN, d1 = DBL_MAX;
printf("double:\n \t%e..%e\n\n",d,d1);
printf("\t所占字节:%d\n\n",sizeof(double));
//char
char c = CHAR_MIN, c1 = CHAR_MAX;
printf("char:\n \t%d..%d\n\n",c,c1);
printf("\t所占字节:%d\n",sizeof(char));
printf("\tchar 类型位数: %d\n\n", CHAR_BIT);
return;
}
/*------------------运行结果-----------------------
int:
-2147483648..2147483647
所占字节:4
float:
1.175494e-038..3.402823e+038
所占字节:4
double:
2.225074e-308..1.797693e+308
所占字节:8
char:
-128..127
所占字节:1
char 类型位数: 8
Press any key to continue
总结:
从运行结果看到,在程序开发过程当中,选择一种合适的数据类型有利于对系统的资源的合理应用。
*/
数据类型 - 整型(int)、字符(char)、浮点(float、double)【5】
最新推荐文章于 2023-01-04 22:01:32 发布