Data Types in C++

Programming languages use several different data types. A data type determines the type of value an object can have and the operations that can be performed. In this article, I’ll walk you through the C ++ data types that you need to know before you start your coding journey towards C ++ programming language.

Variables in C++

A variable is a container (storage area) used to hold data. Each variable must be represented with a unique name. For example, int a = 2; here a is the name of the variable which contains the integer value 2. The value of a can be changed, hence the name of the variable.

Also, Read – Machine Learning Full Course for free.

There are some rules for declaring a variable in C++:

  • Can only have alphabets, numbers, and underscores.
  • Cannot start with a number.
  • Cannot start with an uppercase character.
  • Cannot be a keyword defined in C++ language.

The Fundamental Data Types in C++

In simple terms, Data types are declarations of variables. This determines the type and size of data associated with the variables which are essential to know since different types of data occupy the different size of memory.

data types

Below are the data types that we use in C++ with their meaning and the size in bytes in which a data type can store a value by using a variable:

Data TypeMeaningSize (Bytes)
intInteger4
floatFloating-point4
doubleDouble Floating-point8
charCharacter1
boolBoolean1
voidEmpty0

Except for the above data types, in C++ we also have some other data types known as Derived Data Types and User-Defined Data Types. 

Derived Data Types are the data types that are derived from fundamental (or built-in) data types. For example, arrays, pointers, function, reference. User-Defined data types that are defined by user itself. For example, class, structure, union, enumeration, etc.

I hope you liked this article on the Data Types in C++ programming language. Feel free to ask your valuable questions in the comments section below.

Follow Us:

Aman Kharwal
Aman Kharwal

Data Strategist at Statso. My aim is to decode data science for the real world in the most simple words.

Articles: 1610

Leave a Reply

Discover more from thecleverprogrammer

Subscribe now to keep reading and get access to the full archive.

Continue reading