Datatypes in C++ 11

In this post I describe You all main datatypes in C++ and mathods initialize them.

Datatype in C++, the size of them is different in every OS:

char – it is not signed or it is not unsigned
signed char  0 – 255
unsigned char -128 – 127

signed short(short)
unsigned short

signed int(int)
unsigned int

signed long(long)
unsigned long

signed long long(long long)
unsigned long long

short >= 2 bytes
int >= sizeof(short)
long >= sizeof(int) and long >= 4 bytes
long long >= sizeof(long) and long long >= 8 bytes

The ways of initialize variable:
int a = 105;
int a(105);
int a{105};
int a = {105};
and for zero value:
int b = 0;
int b(0);
int b{};
int b = {0};

example for 123 value:
123 – is int datatype
123L – is long datatype,
123LL – is long long datatype
123UL – is unsigned long datatype
123ULL – is unsigned long long datatype
L letter may be l, U letter may be u letter

bool may be have value true or false.
Zero is convert to false, another values not equals 0 is true

float >= 4 bytes
double >= sizeof(float) and double >= 6 bytes
long double >= sizeof(double)

example for 123.24 value:
123.24 – is double datatype
123.24F – is float datatype
123.24L – is long double datatype
F letter may be f, L letter may be l

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.