第二十篇:定义一个整形变量
#include<iostream>
using namespace std;
int main()
{
cout<<"int 长度为:"<<sizeof(int)<<endl;
cout<<"short 长度为:"<<sizeof(short)<<endl;
cout<<"long 长度为:"<<sizeof(long)<<endl;
cout<<"unsigned short 长度为:"<<sizeof(short)<<endl;
int a = -1; //定义整数型
unsigned b = -1; //定义无符号整数型
short int c = -3;//或者简写为short 只占16位
long int d = -4; //或者简写为long 占4个字节(int在32位是4字节,64位三8字节)
unsigned long e; //长整形
e = a+b+c+d; //计算一下
cout<<"a:"<<a<<"\nb:"<<b<<"\nc:"<<c<<"\nd:"<<d<<"\ne:"<<e<<endl;
return 0;
}