Skip to content Skip to sidebar Skip to footer

Primitive Data types in C++

People are known by their families’ names when they are born. Similarly, every piece of information is of a family. And this family of data together is what we call data types. Now, if you think it’s the end; well, it’s not; there’s a lot more to it, so let’s get started.

So now you know what data types are, so let’s start with its family.

Well, it’s not a nuclear family; it’s a joint one, and this has three sons, or if you’re a feminist reading it for you, three daughters.

  1. Primitive data types,
  2. Derived data types, and last
  3. Abstract or User-defined data types.

But for now, let’s focus on Primitive data types; later, we will discuss the remaining derived and abstract data types.

What is Primitive Data Type?

Primitive data types are the datatypes that are predefined or built-in data types that can be used directly by the programmer to declare a variable.

 These are the types of primitive data types:

  1. Integer
  2. Character
  3. Boolean
  4. Floating Point
  5. Double Floating Point
  6. Valueless or Void
  7. Wide Character

Let’s discuss each of them in detail to clarify the concept better.


The keyword used for integer data types is “int.” for example, 1, 2, 3, etc. They typically require 4 bytes of memory space ranging from -2147483648 to 2147483647. 

For Example:

int size = 69;


As the name suggests, we use the character data type for storing characters, like A, B, a, b, etc. The keyword used for this data type is “char.” Typically it requires 1 byte of memory space and ranges from -128 to 127 or 0 to 255.

For Example:

 char letter = "D";


Now, data types are not only limited to numbers or characters; in the case of some logic, what we require is a true or a false value; for storing such boolean (true or false value) or logical values, we use boolean data type. And “bool” becomes the way or the keyword that we use to use the boolean data type. 

For Example:

bool status_is = false;

Floating Point

Floating-point numbers are used to indicate the decimal or single-precision floating-point based real numbers are the Floating Point data type. Now, the keyword used for this is “float.” And all the Float variables typically require 4 bytes of memory space.

For Example:

float num = 13.14;

Double floating Point

Assume you have a decimal value of 2.3333333333. Now, we can not store this value in the float; for this reason, we have a Double Floating Point data type. We use it for storing double-precision floating-point values or decimal values. And the keyworddouble” is used to represent the double floating-point data type variable. Since it is a double-precision floating-point, its variables typically require 8 bytes of memory space. 

For Example:

double pi = 3.14159;


Well, where there is something, there is nothing, and the same goes with our C++ language; it has int, char, double, float, and hence it also has void, which means without any value. Void is specifically used to create functions or pointers, but you can’t use void to declare variables.

For Example:

void function, void parameter, void name ,etc

Wide Character

After reading the wide-character data type that might have come to your brain, the first thought would be that this data type is just more significant than the char. Well, you are right. This data type is also a character data type with a size more significant than the standard 8-bit data type; it is generally 2 or 4 bytes long. We represent it by “wchar_t.” 

For Example:

wchar_t w = L'D';


So here we got to know all about the extensive knowledge of the core fundamentals in C++, i.e., primitive data types. You can even think of beginning into real-world programming without using primitive data types. Hence you’ve done it well. Practice it once on your compiler/onlinegdb to understand and grasp it well, as coding is all about practical, and theory alone doesn’t render the result and enhance the learning.

Similarly, you must also know that GeekonPeak has just begun, and it is looking for some loyal supporters so we, the new-gen geeky friends, can grow and create more extensive and easy to grasp courses for you (for free). You can follow us on FacebookInstagram & Twitter as well. Also, don’t miss our newsletter subscription. We provide exclusive blogs, tips, tricks, and advice to program efficiently and market smartly. We also promote some of our partners with excellent experiences to share with you. Until next time 🙂

Leave a comment

Sign Up to Our Newsletter

Be the first to know the latest updates