数据类型及范围

DATA TYPESIZE (IN BYTES)RANGE
short int2-32,768 to 32,767
unsigned short int20 to 65,535
unsigned int40 to 4,294,967,295
int4-2,147,483,648 to 2,147,483,647
long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295
long long int8-(2^63) to (2^63)-1
unsigned long long int80 to 18,446,744,073,709,551,615
signed char1-128 to 127
unsigned char10 to 255
float4-3.4*10(-38)~3.4*10(38) 有效位数(6-7)
double8-1.7*10(-308)~1.7*10(308)有效位数(15-16)
long double12-1.2*10(-4932)~1.2*10(4932)
wchar_t2 or 41 wide character

sizeof operator
Queries size of the object or type.
Used when actual size of the object must be known.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
/******************************************************************************
data type

*******************************************************************************/
#include<iostream> 
using namespace std; 
  
int main() 
{ 
    cout << "Size of char : " << sizeof(char)<< " byte" << endl; 
    cout << "Size of int : " << sizeof(int) << " bytes" << endl; 
    cout << "Size of float : " << sizeof(float)<< " bytes" <<endl; 
    cout << "Size of double : " << sizeof(double)<< " bytes" << endl; 
    int a=2147483645;
    cout<<a<<endl;
    cout<<a+2<<endl;
    cout<<a+4<<endl;
    return 0; 
} 

    
Scroll to Top