A data type specifies the type of data or value that a variable can store such as integer, floating, character, double, etc.
Data types in C
There are four types of data type in C language:
- Basic Data Type – int, char, float, double
- Derived Data Type – array, pointer, structure, union
- Enumeration Data Type – enum
- Void Data Type – void
The basic data types are integer-based and floating-point based. C language supports signed and unsigned both literals.
The size of the memory of the basic data types can vary on different bits of the operating system. The size of the memory of data types will be different for 16-bit, 32-bit, and 64-bit operating systems.
The following data type’s size is presented according to the 32-bit operating system:
|Data Types||Memory Size||Range|
|char||1 byte||-128 to 127|
|signed char||1 byte||-128 to 127|
|unsigned char||1 byte||0 to 255|
|short||2 bytes||-32,768 to 32,767|
|signed short||2 bytes||-32,768 to 32,767|
|unsigned short||2 bytes||0 to 65,535|
|int||2 bytes||-32,768 to 32,767|
|signed int||2 bytes||-32,768 to 32,767|
|unsigned int||2 bytes||0 to 65,535|
|short int||2 bytes||-32,768 to 32,767|
|signed short int||2 bytes||-32,768 to 32,767|
|unsigned short int||2 bytes||0 to 65,535|
|long int||4 bytes||-2,147,483,648 to 2,147,483,647|
|signed long int||4 bytes||-2,147,483,648 to 2,147,483,647|
|unsigned long int||4 bytes||0 to 4,294,967,295|
|long double||10 bytes|
Note: for 64-bit memory size will be 2x.