Dafination of Datatype :

A datatype defines the type of data a variable will store in memory. we will discuss all datatype in C++ language.

we will use data type for declaring variables. and if you want to check the datatype size then you can use sizeOf() function in C++.

datatype in c++

Syntax :

datatype_name variable_name =  value;

datatype_name : name of datatype

variable_name: name of a variable.

value: the value of a variable that you want to assign.

Example :

int xyz = 0;
structure of datatype

there are Three types of datatype in C++.

  1. Pre-define datatype (in-Built)
  2. User-define datatype
  3. Derived datatype

1) Pre-define Datatype

predefine datatype is an in-Built datatype. They specify the size of variables in C++.  There are many pre-defined datatypes in c++.

Datatype NameSizeCapacity
int2 Bytes-32768 to +32767
signed int2 Bytes-32768 to +32767
unsigned int2 Bytes0 to +32767
short int2 Bytes-32768 to +32767
unsigned short int2 Bytes0 to +65535
Long int4 Bytes-2147483648 to +2147483647
unsigned long int4 Bytes0 to +4294967295
Integral Datatype
Datatype NameSizeCapacity
float4 Bytes3.4 E-38 to 3.4 E+38
double8 Bytes1.7 E-308 to 1.7 E+308
long double10 Bytes3.4 E-4532 to 1.1 E+4932
Floating Datatype
Datatype NameSizeCapacity
char1 Bytes-128 to +127
unsigned char1 Bytes0 to 255
Character Datatype

User Define Datatype

A data type that is defined by the user it is called user define datatype in C++. Users can create a datatype using the below datatype.

User define Datatype
User Define Datatype

Derived Datatype

Derived datatype is a collection of pre-defined data types. The array is the most useful derived datatype in C++.

Derived define Datatype
Derived define Datatype