C++ Data Types.

C++ Programming Tutorial

C++ Data Types.


Introduction of Data Types

We are creating variables to store data in the C++ language. These data variables are called data types.






Types Data Types

Basic Data Type.

int, char, float, double, etc.

Derived Data Type.

array, pointer, etc.

Enumeration Data Type.

enum.

User Defined Data Type.

structure and class.

Basic Data Types.

Basic data types of data types are found in all programming languages. Because these are the basic data types. Which are mandatory to use. They are.

  1. Integer data type

  2. Float data type

  3. Character data type


Integer data type.

The integer data type only stores whole numbers. The data type found in the integer data type.

Float data type.

Which contains a decimal data stored data type is called float data type.

Character data type.

These data types stores the character in the variables is called a character data type.

User Defined Data Types.

Structure and union in C language are a user-defined data type. This type of data type is also completely allowed in C ++. And at the same time, C ++ provides us the capabilities to create some new user define data types which are known as object-oriented programming.

Class.

Class is an object-oriented programming base data type. And Class is a user-defined data type. The class is also like structure.

class num { your variables and function };

Enum Data Type.

Enum data type is also user define data types. To create an enum data type, we use the enum keyword. And whenever we create Enum data types. So numbers are attached to each of the names. That is, using names like enum keyword automatically assigns names from 0 to values.

enum num {values1, values2, values3};

Derived Data Types.

Derived data types are derived from basic data types.

  1. Arrays.

  2. Functions.

  3. Pointers , etc.


Basic Data Types.

The basic data types are integer-based, floating-point, and character-based. C++ language supports both signed and unsigned literals.

The memory size of basic data types may change according to a 32 or 64-bit operating system.

Let's see the basic data types. It size is given according to 32 bit OS.

Data Types Memory Size Range

char

1 byte

-128 to 127

signed char

1 byte

-128 to 127

unsigned char

1 byte

0 to 127

short

2 byte

-32,768 to 32,767

signed short

2 byte

-32,768 to 32,767

unsigned short

2 byte

0 to 32,767

int

2 byte

-32,768 to 32,767

signed int

2 byte

-32,768 to 32,767

unsigned int

2 byte

0 to 32,767

short int

2 byte

-32,768 to 32,767

signed short int

2 byte

-32,768 to 32,767

unsigned short int

2 byte

0 to 32,767

int

2

-32768 To 32767

Short int

2

-31768 To 32767

Long int

4

-2147483648 To 2147483647

signed int

2

-31768 To 32767

unsigned int

2

0 To 65535

float

4

3.4E-38 to 3.4E+38

double

8

1.7E-308 to 1.7E+308

long double

10

3.4E-4932 to 1.1E+4932