Data Types in C++

Introduction to 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:

Default image
Aman Kharwal

I am a programmer from India, and I am here to guide you with Data Science, Machine Learning, Python, and C++ for free. I hope you will learn a lot in your journey towards Coding, Machine Learning and Artificial Intelligence with me.

Leave a Reply