C语言(二):整型变量的数值范围

发布时间 2023-11-27 22:23:03作者: 代码优雅
#include<stdio.h>
int main()
{
	int a=0;
	while(a<a+1)
	{
		a++;
	}
	printf("int类型的最大值是:%d\n\n",a);
	printf("int类型的最大值+1是:%d\n\n",a+1);

	int b=0;
	while (b>b-1)
	{
		b--;
	}
	printf("int类型的最小值是:%d\n\n",b);
	printf("int类型的最小值-1是:%d\n\n",b-1);

	long c=0;
	while(c<c+1)
	{
		c++;
	}
	printf("long类型的最大值是:%d\n\n",c);
	printf("long类型的最大值+1是:%d\n\n",c+1);

	long g=0;
	while(g>g-1)
	{
		g--;
	}
	printf("long类型的最小值是:%d\n\n",g);
	printf("long类型的最小值-1是:%d\n\n",g-1);

	unsigned long d=0;
	while(d<d+1)
	{
		d++;
	}
	printf("unsigned long类型的最大值是:%u\n\n",d);
	printf("unsigned long类型的最大值+1是:%u\n\n",d+1);

	short e=0;
	while(e<(short)(e+1))
	{
		e++;
	}
	printf("short类型的最大值是:%d\n\n",e);
	printf("short类型的最大值+1是:%d\n\n",(short)(e+1));

	short f=0;
	while(f>(short)(f-1))
	{
		f--;
	}
	printf("short类型的最小值是:%d\n\n",f);
	printf("short类型的最小值-1是:%d\n\n",(short)(f-1));

	return 0;
}