Datatype define the type of data a variable can hold, for example an integer variable can hold integer data, a character type variable can hold character data etc.
Primitive datatype contains:
short, int, long, float, double,and char.
It contains integer value.
It contains integer Decimal value.
It contains integer character.
Datatype | Size (bytes) | Range |
---|---|---|
char | 1 | -128 to 127 or 0 to 255 |
short | 2 | -32,768 to 32,767 |
int | 4 | -2,147,483,648 to 2,147,483,647 |
long | 4 or 8 | -9223372036854775808 to 9223372036854775807 |
unsigned char | 1 | 0 to 255 |
unsigned short | 2 | 0 to 65,535 |
unsigned int | 4 | 0 to 4,294,967,295 |
unsigned long | 4 or 8 | 0 to 18446744073709551615 |
float | 4 | ±3.40282347E+38 |
double | 8 | ±1.7976931348623157E+308 |
long double | 8 or 16 | ±1.1897314953572317650E+4932 |
void | N/A | N/A |
Derived data type is the aggregation of fundamental data type. character, integer, float, and void are fundamental data types. Pointers, arrays, structures and unions are derived data types.
Those data types which are defined by the user as per his/her will are called user-defined data types.
Types of user define Datatype
Structure is a user define datatype. the keyword of structure is 'struct'.
Union is a user define datatype. the keyword of union is 'union'.
Enumration is a user define datatype. the keyword of Enumration is 'enum'.