Data Types in C++
C++ Data Types:
Data Types are used to define the operations and store each of them. It can be classified into three major categories:
-
1. User-defined data type
2. Built-in data type
3. Derived data type
User-defined data type:
In C++, User-defined data types are Structure, Union, Class, enum etc.
struct name { data type member1; data type member2; .............. }
union name { data type member1; data type member2; .............. }
Example :
enum shape{square, cirle}; enum color{blue, green};
Built-in data type:
In C++, Built-in data types are given as follows:
Type | Bytes | Range |
char | 1 | -128 to 127 |
unsigned | 1 | 0 to 255 |
int | 2 | -32768 to 32767 |
unsigned int | 2 | 0 to 65535 |
long int | 4 | -2147483648 to 2147483647 |
unsigned long int | 4 | 0 to 4294967295 |
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 |