C++ Data Types
Variables in C++ allocate the memory to store the values in the program. C++ Data types are the type of data that the variable holds. For example: an integer variable holds integer data types, a character variable holds character data types, string variable holds string data type, etc.
Data Types in C++ is mainly of three types:
- Built-in
- User-defined
- Derived
User Defined Data Types
There are three types of user-defined data types in C++. They are:
- struct
- union
- enum
Built-in Data Types
These data types are also known as primitive data types and the user can directly use it to declare variables.For example:int,bool,float,double etc.
Some of the built-in data types available in C++are:
1.Integer:Size=2 bytes.
int a=5;
2.Float: For single precision floating point.Size=4 bytes.
float z=598.2650;
3.Double: For double precision floating point.Size=8 bytes.
double amount=589896.369847;
4.Character:Size=1 bytes.
char name='X';
5.bool:For booleans,true or false.
bool v=false;
Derived Data Types in C++
There are three types of derived data types in C++. They are listed below:
- Array
- Function
- Pointer