Skip to content

Fundamental Data Types

Fundamental Data Types

A fundamental or primitive type is a data type where the values that it can represent have a very simple nature (a number, a character or a truth-value); the primitive types are the most basic building blocks for any programming language and are the base for more complex data types.

1
2
3
4
bool a = true;
std::cout << "bool a: " << a << std::endl;
std::cout << "sizeof(a): " << sizeof(a) << " bytes" << std::endl;
std::cout << to_bitset(a) << std::endl;

1
2
3
4
int b = 25;
std::cout << "int b: " << b << std::endl;
std::cout << "sizeof(b): " << sizeof(b) << " bytes" << std::endl;
std::cout << to_bitset(b) << std::endl;

1
2
3
4
double c = 1.34;
std::cout << "double c: " << c << std::endl;
std::cout << "sizeof(c): " << sizeof(c) << " bytes" << std::endl;
std::cout << to_bitset(c) << std::endl;

1
2
3
4
char d = 'g';
std::cout << "char d: " << d << std::endl;
std::cout << "sizeof(d): " << sizeof(d) << " bytes" << std::endl;
std::cout << to_bitset(d) << std::endl;

1
2
3
4
long g = 25;
std::cout << "long g: " << g << std::endl;
std::cout << "sizeof(g): " << sizeof(g) << " bytes" << std::endl;
std::cout << to_bitset(g) << std::endl;

1
2
3
4
long long h = 8271;
std::cout << "long long h: " << h << std::endl;
std::cout << "sizeof(h): " << sizeof(h) << " bytes" << std::endl;
std::cout << to_bitset(h) << std::endl;

1
2
3
4
unsigned long i = 987312;
std::cout << "unsigned long i: " << i << std::endl;
std::cout << "sizeof(i): " << sizeof(i) << " bytes" << std::endl;
std::cout << to_bitset(i) << std::endl;

1
2
3
4
unsigned long long j = 4398271;
std::cout << "unsigned long long j: " << j << std::endl;
std::cout << "sizeof(j): " << sizeof(j) << " bytes" << std::endl;
std::cout << to_bitset(j) << std::endl;

1
2
3
4
int8_t k = 25;
std::cout << "int8_t k: " << k << std::endl;
std::cout << "sizeof(k): " << sizeof(k) << " bytes" << std::endl;
std::cout << to_bitset(k) << std::endl;

1
2
3
4
int64_t l = 542;
std::cout << "int64_t l: " << l << std::endl;
std::cout << "sizeof(l): " << sizeof(l) << " bytes" << std::endl;
std::cout << to_bitset(l) << std::endl;

1
2
3
4
float o = 25.54;
std::cout << "float o: " << o << std::endl;
std::cout << "sizeof(o): " << sizeof(o) << " bytes" << std::endl;
std::cout << to_bitset(o) << std::endl;

1
2
3
4
long double p = 987312.325;
std::cout << "long double p: " << p << std::endl;
std::cout << "sizeof(p): " << sizeof(p) << " bytes" << std::endl;
std::cout << to_bitset(p) << std::endl;

1
2
3
4
char d = 'g';
std::cout << "char d: " << d << std::endl;
std::cout << "sizeof(d): " << sizeof(d) << " bytes" << std::endl;
std::cout << to_bitset(d) << std::endl;

Share Snippets